When I was implementing single pure virtual function it was working but now I have two which are not working, can anybody please help me out ?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#include <iostream>
#include <string>
using namespace std;
class Base
{
public :
Base(){};
virtual ~Base (){};
virtual void shuffle(unsigned int steps) = 0;
virtual unsigned int getBlock( unsigned int x, unsigned int y )=0;
};
class Derived1:virtual public Base
{
void shuffle(unsigned int steps)
{
}
};
class Derived2:public Base
{
public :
unsigned int getBlock( unsigned int x, unsigned int y )
{
}
};
int main()
{
Base *b;
Derived1 q;
b = &q;
b->shuffle(1);
Derived2 d;
b = &d;
b->getBlock(0,15);
return 0;
}
|
Last edited on
Line 47. If that was b->getBlock(0,15)
then what would get called?
Since you haven't defined Derived1::getBlock(), it too is an abstract class.
Last edited on