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

理解class与struct申明

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

中国网络支付平台

这几天,关于电商京东收购网银在线的新闻所谓铺天盖地,下面也来看看几家比较有名的中国网络支付平台  支付宝建立于2004年,是国内领先的独立第三方支付平台,支付宝致力于为中国电子商务提供“简单、安全、快速”的在线支付解决方案。财付通是腾讯公司创办的中国领先的…

线程

线程是由两个部分组成的: * 一个是线程的内核对象,操作系统用它来对线程实施管理。内核对象也是系统用来存放 线程统计信息的地方。 * 另一个是线程堆栈,它用于维护线程在执行代码时需要的所有函数参数和局部变量 进程是不活泼的。进程从来不执行任何东西,它只是线程的…

三本优秀的Python教程

 因为突然就对PY感兴趣了~囧~…所以决定找教程学习下(话说到现在还没完整学完一门语言呢…T_T)。相对于其他的程序语言,Python的教程显得单薄。这里推荐三份流传广泛的Python教程,如果你正准备找教程学py,希望本文会对你有用。...…

C栈的实现

C栈的实现…

TBS X5内核SDK静态集成jar完美解决方案

 前言:本篇文章用于解决TBSx5静态无法成功启动的问题...…

虚幻4(ue4)引擎加密pak解包教程(初学者向x64源码逆向)

 前言  遇到了喜欢的游戏,想提取壁纸,于是找quickbms等虚幻4引擎解包工具。无奈游戏加密,无法解包。不知密钥情况下,也没在网上找到现成的加密pak解包工具。想到Unreal4已经开源,就尝试着自己找一下密钥,也算是对照源码的x64逆向分析调试。以前接触的Olly…

发表评论

访客

看不清,换一张

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