This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Why do I get: cannot declare variable ‘sc’ to be of abstract type...
- From: David Daney <ddaney at avtrex dot com>
- To: gcc-help at gcc dot gnu dot org
- Cc: "Johannes P. Schmidt" <jschmidt at avtrex dot com>
- Date: Tue, 31 Jul 2007 09:46:14 -0700
- Subject: Why do I get: cannot declare variable ‘sc’ to be of abstract type...
When I compile this:
------foo.cc----------
class I1
{
public:
virtual void a() = 0;
};
class C1 : public I1
{
public:
void a()
{
}
};
class I2 : public I1
{
public:
virtual void b() = 0;
};
class C2 : public I2, public C1
{
public:
void b()
{
}
};
int main(int argc, char *argv[])
{
C2 sc;
return 0;
}
---------------------
$ g++ -c -g foo.ccfoo.cc: In function ‘int main(int, char**)’:
foo.cc:33: error: cannot declare variable ‘sc’ to be of abstract type ‘C2’
foo.cc:24: note: because the following virtual functions are pure
within ‘C2’:
foo.cc:5: note: virtual void I1::a()
I would think that I1::a() is not virtual because it is defined in the
super class C1. What is going on here?
$ g++ --version
g++ (GCC) 4.1.2 20070502 (Red Hat 4.1.2-12)
Same results for:$ ~/gccsvn/native-clean/gcc/xgcc
-B/home/daney/gccsvn/native-clean/gcc/ --version
xgcc (GCC) 4.3.0 20070728 (experimental)
David Daney