📄 room.cc
字号:
#include <iostream>#include <string>using namespace std;class Room{ int length; int width; int height; int No;public: Room(){} Room( int l, int w, int h, int n ) :length(l),width(w),height(h),No(n) {} int getLength()const { return length; } void setLength( int l ) { length = l; } int getWidth()const { return width; } void setWidth( int w ) { width = w; } int getHeight()const { return height; } void setHeight( int h ) { height = h; } int getNo()const { return No; } void setNo( int n ) { No = n; } void show()const { cout << "length:" << length << endl; cout << "width:" << width << endl; cout << "height:" << height << endl; cout << "No:" << No << endl; }};class ClassRoom : public Room{ int sites; string Class;public: ClassRoom(){} ClassRoom( int l, int w, int h, int n, int s, string c ) :Room(l,w,h,n),sites(s),Class(c) {} int getSites()const { return sites; } void setSites( int s ) { sites = s; } string getClass()const { return Class; } void setClass( string c ) { Class = c; } void show()const { Room::show(); cout << "sites:" << sites << endl; cout << "class:" << Class << endl; }};int main(int argc, char* argv[]){ ClassRoom oc(10,5,3,209,50,"Tarena01"); oc.show(); char buf[100]; cout << "press Enter to continue..."; cin.getline( buf, 100 ); ClassRoom cr; cr.setLength(12); cr.setWidth(6); cr.setHeight(2); cr.setNo(210); cr.setSites(60); cr.setClass("Tarena02"); cr.show(); return 0;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -