?? 程序12.6:獨立實踐2.cpp
字號:
/* 程序12.6:獨立實踐2.cpp:*/
#include<iostream> //包含頭文件
#include<string> //包含頭文件
using namespace std; //使用名字空間std
class Furniture
{
protected:
int numberOfLegs;
int height;
int width;
int length;
public:
virtual void display()=0;
};
class Chair:public Furniture
{
public:
void display()
{
cout<< "顯示Chair"<<endl;
}
};
class Table:public Furniture
{
public :
void display()
{
cout<< "顯示Table"<<endl;
}
};
int main()
{
Furniture *furniture;
char choice;
reEnter:
cout<<"C: for chair"<<endl;
cout<<"T: for table"<<endl;
cout<<"Q: to quit"<<endl;
cout<<"please Enter C,T or Q :";
cin>>choice;
while(choice!='q'&&choice!='Q')
{
switch(choice)
{
case 'c':
case 'C':
furniture=new Chair;
break;
case 't':
case 'T':
furniture=new Table;
break;
default:
cout<<"Invalid option. Enter C,T or Q"<<endl;
goto reEnter;
}
furniture->display();
break;
}
return 0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -