R
Razvan
Hi!
What is wrong with the following code ?
// Test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
class CTest1
{
public:
CTest1(){}
virtual ~CTest1() = 0;
};
class CTest2: public CTest1
{
public:
CTest2(){}
virtual ~CTest2(){}
};
int main(int argc, char* argv[])
{
printf("Hello World!\n");
CTest2 test;
return 0;
}
Because the desctructor for the class CTest1 is pure virtual I cannot
instantiate variables of type CTest2 ?!! Since the destructor is
not inherited the only option is to provide a body for the pure
virtual destrcutor. (I forgot to mention that I get a linker error on
VC++6.0 and VC++7.0)
Is this normal behaviour ? I mean why I cannot instantiate CTest2 ?
Because the destructor is not inherited the fact that the base
destructor is pure virtual should be irrelevant.
Regards,
Razvan
What is wrong with the following code ?
// Test1.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
class CTest1
{
public:
CTest1(){}
virtual ~CTest1() = 0;
};
class CTest2: public CTest1
{
public:
CTest2(){}
virtual ~CTest2(){}
};
int main(int argc, char* argv[])
{
printf("Hello World!\n");
CTest2 test;
return 0;
}
Because the desctructor for the class CTest1 is pure virtual I cannot
instantiate variables of type CTest2 ?!! Since the destructor is
not inherited the only option is to provide a body for the pure
virtual destrcutor. (I forgot to mention that I get a linker error on
VC++6.0 and VC++7.0)
Is this normal behaviour ? I mean why I cannot instantiate CTest2 ?
Because the destructor is not inherited the fact that the base
destructor is pure virtual should be irrelevant.
Regards,
Razvan