The error message says it all really, it's what any sane compiler should give you for the code you've written. You're trying to create an instance of
Base
which is abstract.
In case you don't know, you're trying to create the instance of base when you write
Base::Base()
. It's an unnamed temporary that'll be constructed and destructed immediately but there's still a request to make an object in there.
The only way you're going to make base something you can create instances of is to remove the pure virtual ( = 0 ) from f1 and give it an implementation. Nothing else will do...
And if it "worked" in VC++6.0 that's yet another reason to bury that compiler under several feet of rock and treat it like it's intensely radioactive.
Cheers,
Ash
PS: With reference to the comment below...
Repeat after me - you are not
calling the constructor, you're trying to create an instance of an object. It's a bit confusing as in C++:
Base::f1();
means "explicitly call f1() as found in the class Base on whatever the current object is" but:
Base::Base();
means "reserve a lump of memory big enough for an object of class Base, call it's default constructor on that memory, call it's destructor then drop the memory back in the bit bucket."
Anyway, just remember you don't call constructors (even when using placement
new
, although it comes close) the compiler does for you and ONLY when initialising a new object from raw memory.