Archived

This topic is now archived and is closed to further replies.

hibiki_konzaki

problem with a parameter

Recommended Posts

I found a function in ddutil.cpp, and i took it out of the class it was in so I could use it, but I get an error: C:\Program Files\Microsoft Visual Studio\MyProjects\engine\engine.cpp(285) : error C2664: ''Load_Bitmap'' : cannot convert parameter 4 from ''class CSurface *'' to ''class CSurface ** '' Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast the parameter it''s talking about is :CSurface** ppSurface. I made a CSurface and passed, and I try to pass it to the function, but it gives me that error. I still have ddutil.cpp/h in my project so I can sue the class, I just don''t want to have to restructure my whole program around that class to use it. Hibiki Wheres the any key?

Share this post


Link to post
Share on other sites
See the double asterisk? It means you''re supposed to pass a pointer to a pointer to a class.

In most cases, that means that the function will take care of allocation for you, and return a pointer to the allocated class. So If I had something like

void makeFoo(Foo **fooptr);

I would call it as such:

Foo *myFoo;
makeFoo(&myFoo); // initializes a Foo, sticks it in myFoo
myFoo->doStuff();

Check the function docs to find out what it''s exactly doing, tho.

Share this post


Link to post
Share on other sites