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

理解class与struct申明

webgou17年前 (2010-01-12)编程开发985
出现: 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申明” 的相关文章

C语言中srand随机函数怎么用

[B]设置随机数种子[/B]…

创建纯资源 DLL

创建纯资源DLL: 1。首选是动态DLL 2。把需要的资源导入进项目 3。在编译要/NOENTRY 这个选项,Properties-˃configure Properties-˃linker-˃No entery point...…

游戏资源打包

游戏资源打包几乎是一个网络游戏客户端必备的功能。页游和微端根据实际需求可能不打包资源或者使用小包。资源打包有这么几个好处:1、加快客户端安装时间。拷贝3000个1mb文件所消耗的时间要远大于拷贝一个3g的文件所消耗的时间2、客户端更加整洁,也可以“稍微”避免游戏资源被他人使用…

Unity Shader 极简实践1——极简描边

 1. 极简描边1.1 思路使用两个 Pass 来渲染,两个 Pass 的作用分别是 把模型放大一定倍数,渲染成纯色 正常渲染模型 这样,因为第一个纯色 Pass 把模型放大了,所以第二个正常渲染 Pass 之外能看到一圈纯色的描边,问题在于第一个 Pass 的时候如何把…

CPU、MCU、MPU、DSP的区别?

CPU、MCU、MPU、DSP…

发表评论

访客

看不清,换一张

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