So I wrote the following program to test the limits of inheritance:
Code:
#include <stdio.h>
#include <conio.h>
class baseMomma {
public:
virtual int x ();
virtual int set(int _x);
};
class baby : public baseMomma {
int mx;
public:
virtual int x () {
return mx;
};
virtual int set(int _x) {
int temp = mx;
mx = _x;
return temp;
};
};
int main () {
baseMomma narf[10];
baby Bob;
Bob.set(123456);
narf[3] = Bob;
printf("%d",narf[3].x());
getch();
return 0;
};
and came up with the linker errors:
Code:
[Linker error] undefined reference to `vtable for baseMomma'
[Linker error] undefined reference to `vtable for baseMomma'
[Linker error] undefined reference to `vtable for baseMomma'
Can this be fixed? I'm trying to see what happens if I declare an array of a base object class and fill it with child inherited objects instead, as opposed to making an array of pointers to objects of the base type. I expect it won't work, but I'd like to know a bit more about it. Sorry for the lack of any recognizable question; I'm not sure quite what I'm looking for . So, your thoughts?