正在加载图片...
Implement a inheritance hierarchy u An example of 3 layers, LibMat derives Book, Book derives AudioBook We define a simple public interface, which containing only constructor, destructor and print function(each class has its own print way class libMan public: LibMatoI cout <<"LibMat Default Constructor!<< end; y virtual -LibMatoi cout << "LibMat Destructor! < endl; y virtual void print0 const{cout≤<“ This is a LibMat object!”<<endl; }Implement a inheritance hierarchy ◼ An example of 3 layers: LibMat derives Book, Book derives AudioBook ◼ We define a simple public interface, which containing only constructor, destructor and print function (each class has its own print way) class LibMat { public: LibMat() { cout << “LibMat Default Constructor!” << endl; } virtual ~LibMat() { cout << “LibMat Destructor!” << endl; } virtual void print() const { cout << “This is a LibMat object!” << endl; } };
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有