//pair:對組,可以將兩個值(first,second)視為一個單元(pair),是個模板類。對于map/multimap,就是用pairs來管理value/key的成對元素。任何函數需要回傳兩個值,也需要pair
#include
#include
#include
#include
using namespace std;
void test0()
{
pair product1("tomatoes",3.25);//定義一個組單元
pair product2;
pair product3;
product2.first="lightbulbs";
product2.second=0.99;//設置pair的first,second數據
雅思改分 product3=make_pair("shoes",20.0);//make_pair是個模板函數,返回pair
cout<<"the price of "<
cout<<"the price of "<
cout<<"the price of "<
}
void Test(char h)
{
cout<<"press key===="<
switch(h)
{
case '0': test0();break;
case 27:
case 'q':exit(0);break;
default:cout<<"default "<
}
}
void main()
{
while(1)
{
Test(getch());
}
}