Advertisement

problem with a parameter

Started by July 17, 2002 03:10 PM
1 comment, last by hibiki_konzaki 22 years, 4 months ago
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?
HibikiWheres the any key?www.geocities.com/dragongames123/home.html
find your elementat mutedfaith.com.<º>
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.
Advertisement
Try this:

CSurface mysurf;
MyFunction(&mysurf);

With "&" because the fuction need the memory address of the surface
--------------------------------------------- If God with me, Who against me?Personal Web Samuel Prince Blog...

This topic is closed to new replies.

Advertisement