- 浏览: 399624 次
- 性别:
- 来自: 上海
文章分类
- 全部博客 (309)
- xaml C# wpf (0)
- scala java inner clas (1)
- Tools UML Eclipse UML2 (1)
- Timer .NET Framework (1)
- perl (6)
- python function paramter (1)
- Python Docstring (1)
- Python how to compare types (1)
- Python (8)
- java (5)
- C# (76)
- C# WPF (0)
- p4 (0)
- WPF (46)
- .net (6)
- xaml (1)
- javascript (40)
- windows (10)
- scala (4)
- winform (1)
- c++ (48)
- tools (12)
- cmd (1)
- os (0)
- CI (0)
- shell (0)
- C (2)
- haskell (49)
- functional (1)
- tool (1)
- gnu (1)
- linux (1)
- kaskell (0)
- svn (0)
- wcf (3)
- android (1)
最新评论
How do we duplicate a object through its pointer or reference? suppose
NotQuery *pnq;
NotQuery *pnq2 = new NotQuery(*pnq);
however, what if we have this ?
const Query *pq = pnq->op();
// ???
we cannot dclare a virutal new instance of operator new, the new operator is a static member, and it applies before the constructor.
THINK:??? you can overload new operator inside the class, , however, we cannot make it virtual still it does not answer the time/order problem.
the solution is a surrogate, somehting like this:
public Query { public: virtual Query * clone() = 0; };
however, if we cannot change the return type in the derived class, then we might see this
NameQuery *png = new NameQuery("Rike"); NameQuery *pnq2 = static_cast<NameQuery*> (pnq->clone());
BUT!!!,there is an exception to that "requirement that return type of the derived class must match exactly that of the base class".
so, in the derived class, you can write
public NameQuery : public Query { public: virtual NameQuery* clone() { return new NameQuery(*this); } };
Below shows the whole code ::
class Base { public : Base() { } Base(Base &base) {} virtual Base *clone(); protected: Base *print(); private: }; class Derived : public Base { public: Derived() {} Derived (Derived &derived) : Base(derived) {} virtual Derived *clone(); protected: Base *print(); }; Base* Base::clone(){ return new Base(*this); } Derived* Derived::clone() { return new Derived(*this); }
发表评论
-
不安装Visual Studio,只用Windows SDK搭建VC环境
2013-12-31 21:52 15342首先你需要下载的是 Microsoft Windows S ... -
rpath - runtime search path
2013-04-03 11:36 1012RPath is a very interesting to ... -
C++ - autogenerated copy constructor and assignment operator gotchas
2013-01-24 13:32 772It has been changed that the s ... -
c++ - rethrow a exception gotchas
2012-12-23 10:57 961As in my prevoius example in j ... -
c++ -typeid operator
2012-10-15 22:30 1060typeid is the one of the meager ... -
c++ - dynamic_cast revisit
2012-10-14 21:21 771There are several built-in type ... -
c++ - virtual inheritance example 1
2012-10-14 15:25 823we have discussed the virtual i ... -
c++ - virtual inheritance
2012-10-12 08:58 977As we have discussed in the pos ... -
c++ type of inheritance
2012-09-28 08:58 754There are 3 types of inheritanc ... -
c++ - vritually virtual new
2012-09-27 23:59 960Let's see what if we want to cl ... -
c++ - virtual destructor
2012-09-27 22:01 975As we all know that virtual des ... -
c++ - vritual function and default arguments
2012-09-27 08:56 994As we all know that we virtual ... -
c++ - template specialization and partial specialization
2012-09-26 22:38 1328in this post, we are going to e ... -
c++ - member template in class template
2012-09-26 08:19 939class member template can be us ... -
c++ template class and the pattern to use its friends
2012-09-25 23:47 986template class may defined thei ... -
c++ - Friend declaration in class Template
2012-09-25 08:47 1212There are three kinds of friend ... -
c++ - class template default parameters
2012-09-25 08:18 854the template has parameter, it ... -
c++ - operator new and delete and an example of linked list stores by new/delete
2012-09-24 07:53 588The operator new and delete ope ... -
c++ - delete(void *, size_t) or delete(void *)
2012-09-24 07:18 1170In my previous dicuss, we have ... -
c++ - placement operator new() and the operator delete()
2012-09-23 15:22 873A class member operator new() c ...
相关推荐
matplotlib-3.6.3-cp39-cp39-linux_armv7l.whl
numpy-2.0.1-cp39-cp39-linux_armv7l.whl
基于springboot个人公务员考试管理系统源码数据库文档.zip
onnxruntime-1.13.1-cp310-cp310-win_amd64.whl
基于springboot的西山区家政服务网站源码数据库文档.zip
Linux环境下,关于C++静态库的封装和调用代码。 TestLib是库目录。 TestLibCall是调用库的目录。
基于springboot软件技术交流平台源码数据库文档.zip
numpy-1.20.1-cp39-cp39-linux_armv7l.whl
ASP.NET酒店管理系统源码(WPF) 一、源码特点 采用WPF进行开发的酒店管理系统源码,界面相当美观,功能齐全 二、菜单功能 1、预订登记:可选择入住时间、离店时间、所在城市、证件类型,保存、删除、查询、返回 2、住宿结算:新增入住、保存、删除、查询、返回 3、今日盘点:查询、返回 4、查询统计: 5、房间管理:增加房间类型、删除类型、增加房间、删除房间、保存、返回 6、用户管理:增加用户、删除用户、保存、返回 7、系统配置:基本功能 8、显示当前系统时间等功能的实现
坠落的天空小游戏图片和代码
论文描述:该论文研究了某一特定领域的问题,并提出了新的解决方案。论文首先对问题进行了详细的分析和理解,并对已有的研究成果进行了综述。然后,论文提出了一种全新的解决方案,包括算法、模型或方法。在整个研究过程中,论文使用了合适的实验设计和数据集,并进行了充分的实验验证。最后,论文对解决方案的性能进行了全面的评估和分析,并提出了进一步的研究方向。 源码内容描述:该源码实现了论文中提出的新的解决方案。源码中包含了算法、模型或方法的具体实现代码,以及相关的数据预处理、实验设计和性能评估代码。源码中还包括了合适的注释和文档,以方便其他研究者理解和使用。源码的实现应该具有可读性、可维护性和高效性,并能够复现论文中的实验结果。此外,源码还应该尽可能具有通用性,以便在其他类似问题上进行进一步的应用和扩展。
环境说明: 开发语言:python Python版本:3.6.8 数据库:mysql 5.7 数据库工具:Navicat11 开发软件:pycharm
基于springboot高校学术交流平台源码数据库文档.zip
onnxruntime-1.16.2-cp310-cp310-win_amd64.whl
基于springboot+vue的实践性教学系统源码数据库文档.zip
基于springboot的校园二手物品交易系统源码数据库文档.zip
numpy-1.23.5-cp39-cp39-linux_armv7l.whl
bimdata_api_client-4.0.2-py3-none-any.whl
环境说明: 开发语言:PHP 框架:原生php/thinkphp5 服务器:Apache 数据库:mysql 5.7(一定要5.7版本) 数据库工具:Navicat 11 运行软件:小皮phpStudy
基于SpringBoot的中老年人文化活动平台源码数据库文档.zip