Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

 
 
Thread Tools Display Modes
Prev Previous Post in Thread   Next Post in Thread Next
Old Nov 22nd, 2009, 11:04 PM   #1
CFlower
Newbie
 
Join Date: Nov 2009
Posts: 6
Rep Power: 0 CFlower is on a distinguished road
Problem with pointer in function return

hi all ,
i have problem and three days just trying find out, but no result!!

i have two diffirent classes: Xnode and Ynode
in Ynode, i have method called tree() which it gets as argument - a reference of Xnode (as const) , and it calls its method to return one private variable xx.

void Ynode::tree(const Xnode& x){
       const Node* n=x.list();
       std::cout << n->value;
}
const  Node* Xnode::list() const {
         const Node* nod=xx;
         std:cout << nod->value;
         return nod;
}
the output inside Xnode was good value(as expected) , but the second (after return from list()) -was undefined value - ...56923434.
can you tell me what's wrong? why the pointer is undefined in
const Node* n=x.list(); ??

its little urgent!.

thanks a lot.

Last edited by Ancient Dragon; Nov 23rd, 2009 at 4:31 AM. Reason: replaced icode tags with code tags
CFlower is offline   Reply With Quote
 

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
global vs local pointer with linked lists aatyler C 7 Sep 10th, 2009 7:02 AM
having problem need some help gentleboy C++ 8 Apr 4th, 2009 9:04 PM
simple pointer array w/ function crash codylee270 C 8 Dec 4th, 2005 8:28 PM
Return Strings in Function hbweb500 C# 8 Jul 10th, 2005 8:44 PM
Pointers in C (Part II) Stack Overflow C 2 Apr 29th, 2005 10:39 AM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 3:15 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC