I can't actually figure out what I'm doing wrong here.
So basically I have an object pointer which I pass unto a function to set its value to point to a new Object instance but it doesn't seem to work and I can't resolve why. Below is a code sample of what I'm trying to do.
GetPointer(Object *pointer){
pointer = new Object();
}
in main:
Object *pointer;
GetPointer(pointer);
I also tried initializing the pointer right away and that works so I really can't understand what's wrong with the code above. Any suggestions?
Object *pointer = new Object();
Object*withintand you'll understand why it works the way it does.