Skip to main content
gamedev.net
🔒 Locked

virtual

Started by luasitdown Jan 25, 2006 at 11:53 AM 4 replies 400+ views
Original Post
luasitdown
luasitdown
I remeber just pure virutal function need the define of function. but I found virutual function declaration do not pass linker. why? class Base { virtual void bar(); }; it do not pass linker class Base { void bar(); }; this is ok.
Zahlman
Zahlman
I think this is what you're after...
luasitdown
luasitdown
How to find derived class quickly or automaticly ?

because I add a virtual function in base class, I need add implementation in all derived class. what is convenient way to do it?
Sneftel
Sneftel
Quote:
Original post by luasitdown
because I add a virtual function in base class, I need add implementation in all derived class.
No you don't. You only need that if you've declared it as pure virtual. And then, the compiler will straight-out tell you which classes don't yet have it.
luasitdown
luasitdown
Quote:
Original post by Sneftel
Quote:
Original post by luasitdown
because I add a virtual function in base class, I need add implementation in all derived class.
No you don't. You only need that if you've declared it as pure virtual. And then, the compiler will straight-out tell you which classes don't yet have it.


struct A{	~A(){std::cout<<"dead\n";}virtual aa();	int i;	char c;	long l;};class B:public A{};A *a = new A; // here LNK error

as long as there a virtual function declaration, lnk error arise,if object created.
it pass compiler but it fail to linker. error LNK2001

[Edited by - luasitdown on January 26, 2006 12:51:02 AM]
Sneftel
Sneftel
That's because you haven't even implemented it in the base class.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.