R
Richard Lee
For some reason, this does not compile.
class A
{
public:
class B : public A
{
public:
B() : A() {}
};
protected:
A() {}
};
I can't figure out what is wrong with this construct. It works fine in
other languages (e.g. Java). It's quite useful to be able to declare a
class, and then subclass it a bunch of different ways while scoping the
subclasses to a namespace based on the name of their superclass. I
can't see any semantic problems, since you can declare nested classes in
C++, and you can inherit from classes in C++, but you can't do both?
Maybe it's just a bug in my compiler? I'm using gcc version 4.1.3. Or
is it a flaw in the C++ language specification?
Richard
class A
{
public:
class B : public A
{
public:
B() : A() {}
};
protected:
A() {}
};
I can't figure out what is wrong with this construct. It works fine in
other languages (e.g. Java). It's quite useful to be able to declare a
class, and then subclass it a bunch of different ways while scoping the
subclasses to a namespace based on the name of their superclass. I
can't see any semantic problems, since you can declare nested classes in
C++, and you can inherit from classes in C++, but you can't do both?
Maybe it's just a bug in my compiler? I'm using gcc version 4.1.3. Or
is it a flaw in the C++ language specification?
Richard