当前位置:首页 > 编程开发

理解class与struct申明

webgou17年前 (2010-01-12)编程开发1051
出现: 1>Compiling... 1>stdafx.cpp 1>gof.cpp 1>e:\projects\stu\gof\gof\bridge.h(62) : error C2512: 'CCustomerDataObject' : no appropriate default constructor available 1>e:\projects\stu\gof\gof\bridge.h(68) : warning C4150: deletion of pointer to incomplete type 'CDataObject'; no destructor called 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(74) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(74) : error C2227: left of '->NextRecord' must point to class/struct/union/generic type 1>e:\projects\stu\gof\gof\bridge.h(78) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(78) : error C2227: left of '->PriorRecord' must point to class/struct/union/generic type 1>e:\projects\stu\gof\gof\bridge.h(82) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(82) : error C2227: left of '->AddRecord' must point to class/struct/union/generic type 1>e:\projects\stu\gof\gof\bridge.h(86) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(86) : error C2227: left of '->DeleteRecord' must point to class/struct/union/generic type 1>e:\projects\stu\gof\gof\bridge.h(90) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(90) : error C2227: left of '->ShowRecord' must point to class/struct/union/generic type 1>e:\projects\stu\gof\gof\bridge.h(95) : error C2027: use of undefined type 'CDataObject' 1> e:\projects\stu\gof\gof\bridge.h(55) : see declaration of 'CDataObject' 1>e:\projects\stu\gof\gof\bridge.h(95) : error C2227: left of '->ShowAllRecords' must point to class/struct/union/generic type 代码如下: interface CDataObject; class CCustomerDataObject; class CCustomersBase { public: CCustomersBase(string group)//:_dataObject(NULL) { _dataObject = new CCustomerDataObject(); this->group = group; } virtual~CCustomersBase() { if(_dataObject != NULL) delete _dataObject; } public: virtual void Next() { _dataObject->NextRecord(); } virtual void Prior() { _dataObject->PriorRecord(); } virtual void Add(string customer) { _dataObject->AddRecord(customer); } virtual void Delete(string customer) { _dataObject->DeleteRecord(customer); } virtual void Show() { _dataObject->ShowRecord(); } virtual void ShowAll() { cout<<"Customer Group: " << group<ShowAllRecords(); } private: CDataObject *_dataObject; protected: string group; }; class CCustomerObject:public CCustomersBase { public: CCustomerObject(string group="jsss"):CCustomersBase(group) { } public: // Add separator lines virtual void ShowAll() { cout<<"------------------------"< 0) { _current--; } } void AddRecord(string customer) { _customers.push_back(customer); } void DeleteRecord(string customer) { _customers.pop_back(); } void ShowRecord() { cout<<_customers[_current]<::iterator it = _customers.begin(); it != _customers.end(); it++ ) cout<<" "<<*it< _customers; int _current; }; 类似为:interface A; class B; class C { public: C(){a = new B;//这里编译不通过,应该是class B与interface只是申明 } A* a; }; interface A { public: A(){} }; class B:public A { public: B(){} }; int main(int argc, char* argv[]) { C c;c.a = new B; }

扫描二维码推送至手机访问。

版权声明:本文由知了博客发布,如需转载请注明出处。

本文链接:https://www.webgou.info/?id=112

分享给朋友:

“理解class与struct申明” 的相关文章

unity3d + PureMVC框架搭建

  0、流程:LoginView-SendNotification()---->LoginCommand--Execute()--->调用proxy中的函数操作模型数据--LoginProxy---->接收服务器返回-操作数据-返回通知视图控制器--LoginMediat…

The Basics of Protocols and Delegates

Apple offers a good overview of working with protocols in their Objective-C Programming Reference. However, sometimes a simple working example can go…

[Unity3d]Player Settings导出设置

 unity 导出各个平台设置很方便,最近导出ios时显示状态栏,Status Bar 设置为hide就可以。 可以参考:播放器设置 Player Settings...…

c++运算符优先级

1 :: 左 2 . -˃ [] () 左 3 ++ -- ~ ! - + & * () sizeof new delete castname_cast 单目操作符 右 ...…

vc中error LNK2001:unresolved external symbol _WinMain@16的解决方法

一,问题描述error LNK2001: unresolved external symbol _WinMain@16debug/main.exe:fatal error LNK 1120:1 unresolved externals error executing link.exe;二,产生这个问…

发表评论

访客

看不清,换一张

◎欢迎参与讨论,请在这里发表您的看法和观点。