//---------------------------------
1.h
//---------------------------------
namespace NM
{
class A
{
public:
typedef struct tagStr{int a;} Str;
};
}
//---------------------------------
2.h
//---------------------------------
class B
{
public:
foo(NM::A::Str* pStr);
};
Как предопределить тип NM::A::Str в 2.h?
Здравствуйте, KALAKOM, Вы писали:
KAL>Как предопределить тип NM::A::Str в 2.h?
Можно где-то так, но это не досконально тоже самое.
//type_forward.h
template<class T> class type_forward;
//StrForward.h
#include <type_forward.h>
namespace NM
{
class A;
}
template<>
class type_forward<NM::A>
{
public:
typedef struct tagStr{int a;} Str;
};
//1.h
#include "StrForward.h"
namespace NM
{
class A : public type_forward<NM::A>
{
public:
typedef type_forward<NM::A> Str;
};
}
//2.h
#include "StrForward.h"
namespace NM
{
class B
{
public:
foo(type_forward<A>::Str* pStr);
};
}
[In theory there is no difference between theory and practice. In
practice there is.]
[Даю очевидные ответы на риторические вопросы]
Здравствуйте, KALAKOM, Вы писали:
KAL>//---------------------------------
KAL>1.h
KAL>//---------------------------------
KAL>KAL>namespace NM
KAL>{
KAL>class A
KAL>{
KAL>public:
KAL> typedef struct tagStr{int a;} Str;
KAL>};
KAL>}
KAL>
KAL>Как предопределить тип NM::A::Str в 2.h?
предопределить можно только в классе в который вложен
но определить можно и не в классе в который вложен
//1.h
class A
{
public:
struct tagStr;
typedef struct tagStr Str;
};
//2.h
#include "1.h"
struct A::tagStr{int a;};