D
David Crocker
The following won't compile under Comeau in strict mode, nor under MS
Whidbey beta in ANSI mode. Can anyone tell me why, and which sections of the
ISO standard apply? The error messages from Comeau are:return arg->foo() == bar() // line 45
^
"ComeauTest.c", line 43: error: identifier "Object" is undefined
&& Object
^
<<'bar()' is a public inherited member of the current class and 'Object' is
a protected inherited member of the current class. If I replace them by
this->bar() and this->Object, the errors go away. The source is:>>
#include <typeinfo> // RTTI header
class _eAnyBase
{
public :
_eAnyBase() {}
virtual const std::type_info& foo() const = 0;
virtual const std::type_info& bar() const = 0;
virtual bool _lEqual(const _eAnyBase* h) const = 0;
};
template <class X >
class _eWrapperBase : public _eAnyBase
{
protected:
X Object;
public :
_eWrapperBase(const X& x) : _eAnyBase (), Object(x) {}
const std::type_info& foo() const
{
return typeid(X);
}
const std::type_info& bar() const
{
return typeid(X);
}
};
template <class X >
class _eStorableWrapperBase : public _eWrapperBase<X >
{
public:
_eStorableWrapperBase(const X& x) : _eWrapperBase<X >(x)
{
}
bool _lEqual(const _eAnyBase *arg) const
{
return arg->foo() == bar()
&& Object
== static_cast<const _eStorableWrapperBase<X >* >(arg)->Object;
}
};
enum Enum2 {red, green, blue};
class _eWrapper : public _eStorableWrapperBase<Enum2>
{ // line 54
public:
_eWrapper(const Enum2 & x) : _eStorableWrapperBase<Enum2>(x) {}
};
<<
Thanks - David
Whidbey beta in ANSI mode. Can anyone tell me why, and which sections of the
ISO standard apply? The error messages from Comeau are:return arg->foo() == bar() // line 45
^
"ComeauTest.c", line 43: error: identifier "Object" is undefined
&& Object
^
<<'bar()' is a public inherited member of the current class and 'Object' is
a protected inherited member of the current class. If I replace them by
this->bar() and this->Object, the errors go away. The source is:>>
#include <typeinfo> // RTTI header
class _eAnyBase
{
public :
_eAnyBase() {}
virtual const std::type_info& foo() const = 0;
virtual const std::type_info& bar() const = 0;
virtual bool _lEqual(const _eAnyBase* h) const = 0;
};
template <class X >
class _eWrapperBase : public _eAnyBase
{
protected:
X Object;
public :
_eWrapperBase(const X& x) : _eAnyBase (), Object(x) {}
const std::type_info& foo() const
{
return typeid(X);
}
const std::type_info& bar() const
{
return typeid(X);
}
};
template <class X >
class _eStorableWrapperBase : public _eWrapperBase<X >
{
public:
_eStorableWrapperBase(const X& x) : _eWrapperBase<X >(x)
{
}
bool _lEqual(const _eAnyBase *arg) const
{
return arg->foo() == bar()
&& Object
== static_cast<const _eStorableWrapperBase<X >* >(arg)->Object;
}
};
enum Enum2 {red, green, blue};
class _eWrapper : public _eStorableWrapperBase<Enum2>
{ // line 54
public:
_eWrapper(const Enum2 & x) : _eStorableWrapperBase<Enum2>(x) {}
};
<<
Thanks - David