F
Frank Bergemann
Hi,
the (gcc-3.4.4) compiler complains, if i try to use a typedef of
subclass in superclass:
|padsol15 141> make Helper_test
[CXXD] Helper_test.cc
In file included from Helper_test.cc:17:
Helper.h:258: error: ISO C++ forbids declaration of `BaseType' with no
type
Helper.h:258: error: `::BaseType' is not a valid declarator
Helper.h:258: error: expected `;' before "BaseType"
make: *** [Helper_test.o] Error 1
???
*
* internal base type for shared basics
*/
template<typename X>
class _common
{
public:
typedef X ForType;
typedef X::BaseType BaseType;
typedef _common Super;
BaseType m_data;
/*
operators based on STL predicator specializations of BaseType,
etc, ...
*/
} ;
class wrapper : public _common<wrapper>
{
public:
typedef wrapped_t BaseType; // _common<> can't use that?!
wrapper (wrapped_t data) : Super(data) { /* void */ }
wrapper (wrapper const& rhs) : Super(rhs.m_data) { /* void */ }
~wrapper() { /* void */ }
wrapper& operator=(wrapper const& rhs)
{
if (&rhs != this) {
wrapper x(rhs);
Super::swap(x);
}
return *this;
}
};
the (gcc-3.4.4) compiler complains, if i try to use a typedef of
subclass in superclass:
|padsol15 141> make Helper_test
[CXXD] Helper_test.cc
In file included from Helper_test.cc:17:
Helper.h:258: error: ISO C++ forbids declaration of `BaseType' with no
type
Helper.h:258: error: `::BaseType' is not a valid declarator
Helper.h:258: error: expected `;' before "BaseType"
make: *** [Helper_test.o] Error 1
???
*
* internal base type for shared basics
*/
template<typename X>
class _common
{
public:
typedef X ForType;
typedef X::BaseType BaseType;
typedef _common Super;
BaseType m_data;
/*
operators based on STL predicator specializations of BaseType,
etc, ...
*/
} ;
class wrapper : public _common<wrapper>
{
public:
typedef wrapped_t BaseType; // _common<> can't use that?!
wrapper (wrapped_t data) : Super(data) { /* void */ }
wrapper (wrapper const& rhs) : Super(rhs.m_data) { /* void */ }
~wrapper() { /* void */ }
wrapper& operator=(wrapper const& rhs)
{
if (&rhs != this) {
wrapper x(rhs);
Super::swap(x);
}
return *this;
}
};