cplusplus.com
C++ : Forum : Beginners : Pointer assigned to correct memory locat
 
cplusplus.com
Information
Documentation
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs


post Pointer assigned to correct memory location not working

Vincenzo (5)
Hi,
first of all, the code:

RPC<uint32> local_catalog_address = remote_qp.get_local_catalog();

cout << "local_catalog_address: " << local_catalog_address << endl;

Diagram *catalog;
catalog = (Diagram*) (*local_catalog_address);

cout << "catalog address: " << &catalog << endl;
cout << "catalog is pointing to " << catalog << endl;

cout << catalog->as_string();

local_catalog_address if the momery location of a Diagram object.
When I print "catalog is point to ..." the address is the correct address (&(0x8b4fbe8) for example). I'm sure that the address is correct because I print it on the class containing the method get_local_catalog(), and the addresses match.
I have a segmentation fault when I try to invoke the method as_string(), even if this method is working when used on the other class.
Am I missing something???

Thanks in advance
helios (9402)
I'm not really sure (since I don't know what RPC<> is) but it looks like you're casting local_catalog_address to something it shouldn't be cast to.
Vincenzo (5)
I undestand what you say. In my mind what I think is:

If I have a pointer to an object, whatever it is, and I achieve the goal to make it point to an address where I know there is an istantiation of this object, I can use this pointer.

Reading what you wrote, it seems that my reasoning is wrong. Is it?

Thanks
jsmith (5804)
Vencenzo, please do not post to multiple forums. The thread is also active here:

http://www.cplusplus.com/forum/unices/4377/
Topic archived. No new replies allowed.