P
Plok Plokowitsch
After over a decade of programming in C++ I seem to have missed some
substantial point (mental note: am I getting too old for this?). A
little bit of help would be *very* appreciated.
I'm trying to gather various different classes into a common namespace
using typedefs:
class QWidget {};
class MyListview {};
namespace gui
{
typedef QWidget Widget;
typedef MyListview Listview;
}
Thus, I can refer to these classes as gui::Widget and gui::Listview
regardless of their actual origin. So far so good.
Unfortunately, I need to forward declare these classes in a header:
namespace gui { class Widget; }
namespace gui { class Listview; }
At some point, the forward declaration "meets" the typedef. This is
where the compiler disagrees: the forward declaration is in conflict
with the typedef.
error C2371: 'gui::Widget' : redefinition; different basic types, see
declaration of 'gui::Widget'
error C2371: 'gui::Listview' : redefinition; different basic types,
see declaration of 'gui::Listview'
Is the type defined using typedef not a class? How else should I
define the namespace or change the forward declaration?
Here is a complete example:
class QWidget {};
class MyListview {};
namespace gui { class Widget; }
namespace gui { class Listview; }
namespace gui
{
typedef QWidget Widget;
typedef MyListview Listview;
}
void main() {}
Please help an old man Thanks,
Stoyan.
Btw, just in case this is relevant:
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for
80x86
substantial point (mental note: am I getting too old for this?). A
little bit of help would be *very* appreciated.
I'm trying to gather various different classes into a common namespace
using typedefs:
class QWidget {};
class MyListview {};
namespace gui
{
typedef QWidget Widget;
typedef MyListview Listview;
}
Thus, I can refer to these classes as gui::Widget and gui::Listview
regardless of their actual origin. So far so good.
Unfortunately, I need to forward declare these classes in a header:
namespace gui { class Widget; }
namespace gui { class Listview; }
At some point, the forward declaration "meets" the typedef. This is
where the compiler disagrees: the forward declaration is in conflict
with the typedef.
error C2371: 'gui::Widget' : redefinition; different basic types, see
declaration of 'gui::Widget'
error C2371: 'gui::Listview' : redefinition; different basic types,
see declaration of 'gui::Listview'
Is the type defined using typedef not a class? How else should I
define the namespace or change the forward declaration?
Here is a complete example:
class QWidget {};
class MyListview {};
namespace gui { class Widget; }
namespace gui { class Listview; }
namespace gui
{
typedef QWidget Widget;
typedef MyListview Listview;
}
void main() {}
Please help an old man Thanks,
Stoyan.
Btw, just in case this is relevant:
Microsoft (R) 32-bit C/C++ Standard Compiler Version 13.10.3077 for
80x86