C++ std_pair用法

来源:互联网 发布:淘宝新手开店视频教程 编辑:程序博客网 时间:2024/06/05 09:56
#include <iostream>#include <utility>#include <string>using namespace std;int main () {  pair <string,double> product1 ("tomatoes",3.25);  pair <string,double> product2;  pair <string,double> product3;  product2.first = "lightbulbs";     // type of first is string  product2.second = 0.99;            // type of second is double  product3 = make_pair ("shoes",20.0);  cout << "The price of " << product1.first << " is $" << product1.second << "\n";  cout << "The price of " << product2.first << " is $" << product2.second << "\n";  cout << "The price of " << product3.first << " is $" << product3.second << "\n";  return 0;}
0 0
原创粉丝点击