Q
Quentin
Dear Gurus,
This is a fairly simple question, but I can't figure out what the answer is.
I can easily change my code, but I want to know why I can't do this to
further my knowledge of the C++ language (and OO):
class a
{
public:
a(){ vm(); }
virtual void vm() = 0;
};
class b : public a
{
public:
void vm() { }
};
int main()
{
b B;
return 0;
}
VC++ says: "error LNK2001: unresolved external symbol "public: virtual void
__thiscall a::vm(void)"
I understand that 'a' doesn't have a implementation of 'vm', but also I
cannot create an instance of 'a' either (because it has a pure virtual
function) so when I create a 'b' why can't 'a's constructor call 'b's 'vm'?
Quentin.
This is a fairly simple question, but I can't figure out what the answer is.
I can easily change my code, but I want to know why I can't do this to
further my knowledge of the C++ language (and OO):
class a
{
public:
a(){ vm(); }
virtual void vm() = 0;
};
class b : public a
{
public:
void vm() { }
};
int main()
{
b B;
return 0;
}
VC++ says: "error LNK2001: unresolved external symbol "public: virtual void
__thiscall a::vm(void)"
I understand that 'a' doesn't have a implementation of 'vm', but also I
cannot create an instance of 'a' either (because it has a pure virtual
function) so when I create a 'b' why can't 'a's constructor call 'b's 'vm'?
Quentin.