close

#include <iostream>
/* 咖啡店點飲料 */
using namespace::std;
class Cafeshop
{
public:
void menu(string drink)
{
makedrink=drink;
}
string tellservice()
{
return makedrink;
}
void printreceipt()
{
cout<<"Welcome to the Niki cafe shop!You drinks:"<<tellservice()<<endl;
}
private:
string makedrink;
};
int main()
{
string youlike;
Cafeshop myorder; //建一個Cafeshop名為myorder
cout<<"Which kind drink you want?"<<endl;
getline(cin,youlike); //輸入字串
myorder.menu(youlike);
myorder.printreceipt();
system("PAUSE");
return 0;
}
顯示結果:
Which kind drink you want?
apple juice
Welcome to the Niki cafe shop!You drinks:apple juice
文章標籤
全站熱搜