[gameprogrammer] Re: Pure virtual function getting called
- From: Ryan Anderson <ryan@xxxxxxxxxxxxxx>
- To: gameprogrammer@xxxxxxxxxxxxx
- Date: Wed, 19 May 2004 19:51:41 -0600
Kevin Jenkins wrote:
>I have this in the base class
>virtual char* GetClassName(void) const=0;
>
>This in the derived class
>virtual char* GetClassName(void) const {return "Player";}
>
>Yet when I call GetClassName within the base class constructor, it is still
>calling the base class version of GetClassName and complaints about calling
>a pure virtual function.
>
>On a similar topic, all GetClassName does is return the name of the class it
>is enclosed in. I made it pure virtual so the users wouldn't forget to
>define it. But if there is an automatic way to do this please let me know.
>
>
>
>---------------------
>To unsubscribe go to http://gameprogrammer.com/mailinglist.html
>
>
>
>
I actually ran into this problem recently...
On some compliers, you cannot call a virtual method on a class from that
class's constructor.
Kinda odd I know, but that's what I found. I'm sure someone on this list
can tell you the how's and why's of it, 'cause I'm not sure why exactly
(something to do with vptr tables or something) but you can't do it.
-Ryan Anderson
Worlds Apart Productions
---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html
- References:
- [gameprogrammer] test
- From: Dave Slutzkin
- [gameprogrammer] Re: test
- From: David Olofson
- [gameprogrammer] Re: test
- From: Dave Slutzkin
- [gameprogrammer] Pure virtual function getting called
- From: Kevin Jenkins
Other related posts:
- » [gameprogrammer] Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- » [gameprogrammer] Re: Pure virtual function getting called
- [gameprogrammer] test
- From: Dave Slutzkin
- [gameprogrammer] Re: test
- From: David Olofson
- [gameprogrammer] Re: test
- From: Dave Slutzkin
- [gameprogrammer] Pure virtual function getting called
- From: Kevin Jenkins