|
ADT problems -long
Im having problems with a few classes of mine they are ADTs and multiply inherited, here is the code:
I put the /FORCE flag on for the linker, so it builds and runs fine, but if I dont /FORCE then it wont link, and either way i get these errors, ive done everything I can to get rid of them, and the only thing that works is getting rid of the definitons for CObject::Update(); and CWntity::Update();, and I dont want to do that! what I am trying to do is instead of having to rewrite all of the Update() method for every derived class i just put the base class's Update function into the derived classes Update function, so when I go to CMD2Entity::Update(), it will call CEntity::Update(), which in turn will call CObject::Update(), etc. this is why i want to keep the definitions for the Update() methods even though they are pure virtual,
sorry for being so long winded and making such a code dump here, (i dont have a website i oculd've put the source code on) thanks in advance
[EDIT]
some of the C-style comments got messed up sorry aobut that ;(
Edited by - asaari on August 15, 2001 5:21:39 AM
Patience...
If you define a function in a header file, and include that header file more than once (eg. in snow.cpp and MD2Entity.cpp, perhaps?) then it gets compiled more than once, and the linker sees it more than once.
Put function definitions in the cpp files, not the headers. The only good reason to put function definitions in headers is when you want them to be inline, and you can''t make virtual functions inline.
If you define a function in a header file, and include that header file more than once (eg. in snow.cpp and MD2Entity.cpp, perhaps?) then it gets compiled more than once, and the linker sees it more than once.
Put function definitions in the cpp files, not the headers. The only good reason to put function definitions in headers is when you want them to be inline, and you can''t make virtual functions inline.
CObject and CEntity only have one function definition a piece so I was trying to save space, and the implementations are within the #ifndef and #endif, ill try putting themn in cpp files though
Edited by - asaari on August 16, 2001 11:49:49 PM
Edited by - asaari on August 16, 2001 11:49:49 PM
thankyou!!! it worked, but now I have another problem,
in object.h I #include so that i can glTranslatef(), but when i do this, i get some strange errors...
now i know there cant be a problem with my gl.h
, and all is good if i take it out of object.h (it is included in other parts of the program as well, any ideas? thanks in advance
in object.h I #include
|
now i know there cant be a problem with my gl.h

Hmm, multiple inheritence is generally Bad with a capital B. If you can rework your design so it is single inheritance (unless all but 1 class are pure virtual abstract classes).
Ohhh, your lucky I''m not in an OO evangilist mood!!
Have a nice day
Brad
Ohhh, your lucky I''m not in an OO evangilist mood!!

Have a nice day
Brad
the only classes I have that are not ADTs are CMD2Entity, and CMD2Model, both CObject and CEntity are abstract, and to do single inheritance here I think i would have to cut and paste all of the MD2 class into the MD2Entity class, and that seems really messy, and unnecessary
No idea how to fix that, but it looks like WINGDIAPI isn''t defined. Make sure you have all the relevant #includes there. (wingdi.h might be your first call.)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement