• Advertisement

Archived

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

problem with a parameter

This topic is 5697 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
Advertisement
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
Try this:

CSurface mysurf;
MyFunction(&mysurf);

With "&" because the fuction need the memory address of the surface

Share this post


Link to post
Share on other sites

  • Advertisement