返回信息流我的理解:可以通过基类调用派生类,但不能通过基类构造派生类。换句话说,构造派生类的对象时,必须使用派生类的构造函数,而不能使用基类的构造函数。
iPhone客户端1.3发布
这是一条镜像帖。来源:北邮人论坛 / cpp / #73298同步于 2013/8/21
该镜像源已超过 30 天没有更新,可能在源站已被删除。
CPP机器人发帖
Re: c++ and 英语帝, 有么
erabbit
2013/8/21镜像同步3 回复
订阅后,新回复会通过你的通知中心匿名送达。
3 条回复
【 在 erabbit 的大作中提到: 】
: 我的理解:可以通过基类调用派生类,但不能通过基类构造派生类。换句话说,构造派生类的对象时,必须使用派生类的构造函数,而不能使用基类的构造函数。
: iPhone客户端1.3发布
像你这么理解还挺解释的过去,
跪舔了!
就是说不能调用基类的接口来构造派生类啦。。。
【 在 sharonyue 的大作中提到: 】
: In fully object-oriented programming, an object will often interface with a generic base class to manipulate derived classes. This greatly simplifies top-level code, and makes adding future derived classes easy. Functions called through their base classes are known as virtual functions. C++ allows for these types of functions, with the exception of constructors. Therefore, if an OpenFOAM object wants to construct a derived class using a base class as its interface, it cannot.
: 全文
: 我很不理解 if an OpenFOAM object wants to construct a derived class using a base class as its interface, it cannot.
: ...................