16,548
社区成员




我有定义了一个类CInfomation:
class CInfomation
{
public:
CInfomation(CTime time, CString s1,CString s2);
virtual ~CInfomation();
};
类CForumInfo:
class CForumInfo : public CInfomation
{
public:
CForumInfo(CTime time, CString s1,CString s2);
virtual ~CForumInfo();
};
B的构造函数是这样写的:
CForumInfo::CForumInfo(CTime time, CString s1,CString s2):CInfomation(time,s1,s2)
{
}
然后我有这样使用:
CArray <CInfomation, CInfomation&> infoes;
CForumInfo forumInfo1(CTime::GetCurrentTime(),"haha","heihei");
CForumInfo forumInfo2(CTime::GetCurrentTime(),"haha","heihei");
infoes.Add(forumInfo1);
infoes.Add(forumInfo2);
编译的时候就会出现错误:
error C2512: 'CInfomation' : no appropriate default constructor available
这个怎么解决啊?
我用CArray就是想做一个A的数组,里面包含派生自A的B等对象。
第一次用CArray这种高级的东西,就碰壁了!!!