Pointers in C++
Posted on 2004-08-16
My problem is to do with pointers. What I am trying to do is pass a pointer to a function defined in a seperate file. That function is then going to create an object which the pointer will then reference. Is this at all possible? At the moment, I seem to be getting back nothing from the function, or it is not changing the pointer that I'm passing. Basically it goes like this:
in the other file:
int define_pointer(object *obj)
obj = create_and_initialise_object(); // this function does return a pointer to the proper object
I'm probably doing something stupid, like scoping issues or something, but I don't know what it is.
For some more info: I'm doing this for a DirectDraw project , and the pointer that I'm passing is a LPDIRECTDRAWSURFACE7, and I've got a function which creates the surface and passes a pointer back.
Any help you could provide would be much appreciated.