close
#include <iostream>
 
/* 咖啡店點兩杯飲料 */
 
using namespace::std;
 
class Cafeshop
{
    public:
 
    Cafeshop(string drink)
{
    menu(drink);
}

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() 
{
    //宣告兩個 Cafeshop物件一個是 Nikilike另一個是Misalike

Cafeshop Nikilike("Niki want drinks cafe!");

Cafeshop Misalike("Misa want drinks Mocha!");

cout<<"Which kind drink you want?"<<endl

   <<Nikilike.tellservice()<<endl

   <<Misalike.tellservice()<<endl;

Nikilike.printreceipt();

Misalike.printreceipt();
 

system("PAUSE");
return 0;

}

 

顯示結果:

Which kind drink you want?

Niki want drinks cafe!

Misa want drinks Mocha!

Welcome to the Niki cafe shop!You drinks:Niki want drinks cafe!

Welcome to the Niki cafe shop!You drinks:Misa want drinks Mocha!

arrow
arrow
    文章標籤
    c++
    全站熱搜

    布拉怡 發表在 痞客邦 留言(0) 人氣()