在 linux 怎么不通!!!//A.h#ifndefA_H#defineA_HclassA{public:enumType{A1,A2,A3}}#endif//B.h#ifndefB
在 linux 怎么不通!!!
//A.h
#ifndef A_H
#define A_H
class A
{
public:
enum Type {A1,A2,A3};
};
#endif
//B.h
#ifndef B_H
#define B_H
class B
{
A::Type type;
public:
B(A::Type type1=A::Type::A1);
}
#endif
//B.cpp
#include "A.h "
#include "B.h "
B::B(type1)
{
type = type1;
}
执行g++ -c B.cpp -I /home/xixi
总是提示 XXX is not an aggreagate type!!!
请高手解答,谢谢!!!
[解决办法]
3个问题:
#ifndef B_H
#define B_H
class B
{
A::Type type;
public:
B(A::Type type1=A::A1); //gcc不支持A::Type::A1,因为Type不是类
} ; //少;号
#endif
#include "A.h "
#include "B.h "
B::B(A::Type type1) //定义不对
{
type = type1;
}
