class A
{
public:
virtual void x();
void test()
{
x();
}
};
class B : public A
{
public :
virtual void x()
{
cout << "B" << endl;
}
};
[edited by - PrettySneaky on April 12, 2004 4:28:16 AM]
[edited by - PrettySneaky on April 12, 2004 4:32:56 AM]
[edited by - PrettySneaky on April 12, 2004 4:33:46 AM]
Virtual functions + linking errors
I currently writing my first game and a problem has arisen. When i try to call a virtual function from my base class I get a linker error.
This piece of code generate the same error. I use Visual Studio .NET...
Post the error. Also, which of those functions have you actually provided bodies for?
"Sneftel is correct, if rather vulgar." --Flarelocke
"Sneftel is correct, if rather vulgar." --Flarelocke
Sorry forgot to add the body to the x function i B. Fixed the first messge now..
the error mess was:
error LNK2001: unresolved external symbol "public: virtual void __thiscall A::x(void)"(?x@A@@..etc)
If A::x() is virtual, you''ll need to either declare it pure virtual, or give it a body.
"Sneftel is correct, if rather vulgar." --Flarelocke
"Sneftel is correct, if rather vulgar." --Flarelocke
OK!! So now the code builds and compiles just fine. But during run-time i get this annoying Debug error message.
It says something like:
Debug error!
Program d:\....etc..
R6025
-pure virtual function call
Abort Retry Ignore
What''s going on??
Sorry if i''m being insulting for asking this but you are trying to call the method from a base class pointer to a derived object aren''t you?
Also you didn''t cast the object to its base?
If you don''''t gosub a program loop you''''ll never get a sub-routine - Kryten Red Dwarf
Also you didn''t cast the object to its base?
If you don''''t gosub a program loop you''''ll never get a sub-routine - Kryten Red Dwarf
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement