C++继承的经典程序

时间:2014-07-16 06:29:52
【文件属性】:

文件名称:C++继承的经典程序

文件大小:26KB

文件格式:DOC

更新时间:2014-07-16 06:29:52

继承

class Derived : public Base { private: int d_number; public: // constructor, initializer used to initialize the base part of a Derived object. Derived( int i, int j ) : Base(i), d_number(j) { }; // a new member function that overrides the print( ) function in Base void print( ) { cout << get_number( ) << " "; // access number through get_number( ) cout << d_number << endl; } };


网友评论