C++ Does pointer of pointer automatically have access to new value?

raiskader

I am having a hard understanding of how pointers to pointers should work, like in the following example.

let's say I have in a class in a certain file the following

typedef object*    objectPtr;

and another file containing

struct RandomStruct
{
    RandomStruct( objectPtr* obj = NULL ): ojbOwner( obj ) {}
    objectPtr*     objOwner;
}

I use both of these as members of another class and construct them like this

Constructor():
objectPtrMember( NULL )
, RandomStructMember( &objectPtr ){}

I then proceed to update my objectPtrMember variable through an editor at runtime to point to an object, and where my logic tells me that objOwner would be updated as well, since it points to objectPtrMember which was updated through the editor, my editor program says otherwise as objOwner stays NULL.

is there something I may understand wrong about pointers ? or am I just not doing the right thing ?

eerorika
typedef object*    objectPtr;

Avoid obfuscating pointer types like this.

NULL

NULL shouldn't be used in new C++ programs. It exists for backward compatibility. Use nullptr instead.

my logic tells me that objOwner would be updated as well

is there something I may understand wrong about pointers ?

Yes, there is something wrong in your understanding. Modifying one pointer will not cause another pointer to be modified.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Why does the value of a pointer of a pointer have undefined behaviour?

Passing and Assigning New Value to Pointer C++

c++ delete pointer and then access the value of it points to

Does it cost to convert pointer to value in c++?

Update pointer value in struct automatically

How to return C pointer automatically

Is dereferencing a pointer an alias for the pointed variable or does it just access the value of the variable?

Copy a C++ object at a pointer to a new pointer

how to pass a pointer to struct to another function in C, in calling function if I have access to only pointer variable

Is it possible to have an argument for a pointer in C++ and what does that mean?

Why does object have NULL vtable pointer in C++?

Value of Pointer in C

Pointer losing value in C

Pointers in C(Value of a pointer)?

Can you have function pointer with assigned parameter value in C?

C++ - Does anyone have any tricks for analyzing pointer to pointer problems?

Access to another struct by value or by pointer

access the value of array by pointer in CLR

Access and store value by index in a pointer

Access the value using pointer in Ada

C : enQueue : How does create a new pointer to the tail?

Getting value from struct by pointer to pointer in C

Passing new value to a pointer via a recursive function in c++

Are there any differences between indirection and Dereferencing when they access the value of a pointer in C?

"C" Trying to understand **pointer and how to access all values of value[][]

Multiple New Objects Have The Same Pointer Addresses

In C, does assigning a struct to a struct pointer assigns a copied value of the struct?

What exactly does value initialization of a pointer do in C++?

Does the C standard permit assigning an arbitrary value to a pointer and incrementing it?