I've made a chessboard but my constructor fails to create objects of my derived class, it sais it's abstract because I got virtual = 0 functions. But in my book of C++ it is possible that you have a base class with pure virtual functions and in the derived classes you fill them in?
Can someone please take a look at the code?
here is my dropbox link with the rar off the files:
You can't instantiate an abstract class. You can, as you say, have pure virtual functions in class A, and then implement them in child classes of A, in which case you can instantiate those child-classes, but you can't instantiate A.
You probable have undefined a pure virtual function in your derived class. check it out. There SHOULD NOT be any pure virtual function in order to instantiate a class.
Well I've double checked the code again and I don't find a pure virtual function in my derived class.
Here are the errors because of this 2 lines:
bord[1][kolom] = new Schaakstuk(Schaakstuk::WIT);
bord[6][kolom] = new Pion(Schaakstuk::ZWART);
errors:
spelbord.cpp(31): error C2259: 'Pion' : cannot instantiate abstract class
1> due to following members:
1> 'bool Schaakstuk::ZetIsLegaal(int,int,int,int)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(15) : see declaration of 'Schaakstuk::ZetIsLegaal'
1> 'void Schaakstuk::PrintStuk(void)' : is abstract
1> c:\users\don\desktop\schaakbordbug\schaakstuk.h(16) : see declaration of 'Schaakstuk::PrintStuk'
1> 'void Schaakstuk::GeefCor(int [][2],int,int,int,int)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(17) : see declaration of 'Schaakstuk::GeefCor'
1> 'bool Schaakstuk::IsPion(void)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(19) : see declaration of 'Schaakstuk::IsPion'
1>c:\users\dd\desktop\schaakbordbug\spelbord.cpp(31): error C2664: 'Pion::Pion(const Pion &)' : cannot convert parameter 1 from 'Schaakstuk::kleurType' to 'const Pion &'
1> Reason: cannot convert from 'Schaakstuk::kleurType' to 'const Pion'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
1>c:\users\dd\desktop\schaakbordbug\spelbord.cpp(32): error C2259: 'Pion' : cannot instantiate abstract class
1> due to following members:
1> 'bool Schaakstuk::ZetIsLegaal(int,int,int,int)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(15) : see declaration of 'Schaakstuk::ZetIsLegaal'
1> 'void Schaakstuk::PrintStuk(void)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(16) : see declaration of 'Schaakstuk::PrintStuk'
1> 'void Schaakstuk::GeefCor(int [][2],int,int,int,int)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(17) : see declaration of 'Schaakstuk::GeefCor'
1> 'bool Schaakstuk::IsPion(void)' : is abstract
1> c:\users\dd\desktop\schaakbordbug\schaakstuk.h(19) : see declaration of 'Schaakstuk::IsPion'
1>c:\users\dd\desktop\schaakbordbug\spelbord.cpp(32): error C2664: 'Pion::Pion(const Pion &)' : cannot convert parameter 1 from 'Schaakstuk::kleurType' to 'const Pion &'
1> Reason: cannot convert from 'Schaakstuk::kleurType' to 'const Pion'
1> No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
Is my first C++ project on the university so I'm not convientfamiliar with the error messages.