Re: Calling a pure virtual function

2005-07-11 Thread Jonathan Wakely
On Sat, Jul 09, 2005 at 08:41:47PM +1000, Adam Nielsen wrote: > Hi all, > > I was expecting the following code snippet to work, so am I doing > something wrong, or is there an issue with GCC? I was under the > impression that this is allowed, according to > http://www.parashift.com/c++-faq-lite/

Re: Calling a pure virtual function

2005-07-09 Thread Florian Weimer
ly as GCC should be able to tell at compile > time the base constructor is calling a pure virtual function. I guess > it's treating the constructor like any other function, where this > behaviour would be permitted. I think C++ allows for a definition for a purely abstract function (which would be called in this case).

Re: Calling a pure virtual function

2005-07-09 Thread Adam Nielsen
d a compiler error (something along the lines of 'you can't call a pure virtual function') rather than a linker error. Especially as GCC should be able to tell at compile time the base constructor is calling a pure virtual function. I guess it's treating the constructor like any

Re: Calling a pure virtual function

2005-07-09 Thread Lion Vollnhals
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > I was under the > impression that this is allowed, according to > http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.1 See [23.3]. You aren't allowed to call the virtual function from the Base class constructor. - -- Lion Vollnha

Re: Calling a pure virtual function

2005-07-09 Thread Florian Weimer
* Adam Nielsen: > class Base { > public: > Base() > { > cout << "This is class " << this->number(); > } > > virtual int number() = 0; > }; Roughly speaking, when number() is invoked, the object still has type Base (with a corresponding vtable). One's constructor will chan

Re: Calling a pure virtual function

2005-07-09 Thread Lion Vollnhals
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 > It seems like GCC initially allows it as it starts to compile okay, but > then I get an undefined reference error from the linker (because it > seems to be actually calling Base::number(), which obviously won't work > as it's a pure virtual function.

Calling a pure virtual function

2005-07-09 Thread Adam Nielsen
Hi all, I was expecting the following code snippet to work, so am I doing something wrong, or is there an issue with GCC? I was under the impression that this is allowed, according to http://www.parashift.com/c++-faq-lite/strange-inheritance.html#faq-23.1 It seems like GCC initially allows it as