Code:
class Table
{
protected:
// variables for all subclasses
public:
Table(int sizeOfTable);
}
Table::Table(int capacity)
{
sizeOfTable = capacity
// initialise other variables
}
class roundTable: public Table
{
public:
roundTable(int capacity) : Table (capacity){}
//declare subclass variables
}
I have found out (the hard way) that I cannot simply put a virtual function in the constructor for 'Table'.
However, I cannot seem to find any alternative to this, I have looked at passing values up from the derived class but this doesn't seem to fit my problem at all.
Is there an easy way around this or am I looking at this problem the completely wrong way?
I can easily create an initialisation function in the subclass and call it in the main method, but I'm hoping there is a way to do it as I have described above.
Any help is much appreciated.
