I did find one problem that I can't quite figure out
int World::AddObjectToWorld(int type){ Object * Obj = NULL; switch (type) { case OBJ_CROSS: Obj = new Cross(); break; } if (Obj != NULL) { World::AddObjectToWorld(Obj); }}
When AddObjectToWorld is referenced in my header file, it says it takes an int, and that is fine, up until this part.
World::AddObjectToWorld(Obj);
We get an error like this
--------------------Configuration: NeHeGL - Win32 Debug--------------------Compiling...World.cppc:\documents and settings\jonathan\desktop\renderengine\world.cpp(20) : error C2664: 'AddObjectToWorld' : cannot convert parameter 1 from 'class Object *' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style castGenerating Code...Compiling...NeHeGL.cppGenerating Code...Skipping... (no relevant changes detected)Renderer.cppError executing cl.exe.Creating browse info file...NeHeGL.exe - 1 error(s), 0 warning(s)
I did find this in the MSDN
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/express_76.asp
I think this is what I need to do but I'm not sure how to implement it.
I tried, but failed
int World::AddObjectToWorld(int type){ Object * Obj = NULL; Obj = reinterpret_cast<Object>( type ); switch (type) { case OBJ_CROSS: Obj = new Cross(); break; } if (Obj != NULL) { World::AddObjectToWorld(Obj); }}
Now it just tells me I can't turn Obj into an Object class, and an int into an Obj...
--------------------Configuration: NeHeGL - Win32 Debug--------------------Compiling...World.cppc:\documents and settings\jonathan\desktop\renderengine\world.cpp(10) : error C2440: 'reinterpret_cast' : cannot convert from 'int' to 'class Object' Conversion requires a constructor or user-defined-conversion operator, which can't be used by const_cast or reinterpret_castc:\documents and settings\jonathan\desktop\renderengine\world.cpp(21) : error C2664: 'AddObjectToWorld' : cannot convert parameter 1 from 'class Object *' to 'int' This conversion requires a reinterpret_cast, a C-style cast or function-style castError executing cl.exe.Creating browse info file...NeHeGL.exe - 2 error(s), 0 warning(s)
[Edited by - Shamino on December 14, 2005 9:04:15 PM]
----------------------------------------------------------Rating me down will only make me stronger.----------------------------------------------------------