C++primer 9.3.2节练习
练习9.23
四个数的值将会相同,都是c容器中那一个唯一的值;
练习9.24
1 #include <iostream> 2 #include <vector> 3 #include <list> 4 #include <deque> 5 #include <string> 6 #include <iterator> 7 8 using namespace std; 9 10 11 int main() 12 { 13 vector<int> v{ 1,2,3,4,5 }; 14 cout << v.at(0) << endl; 15 cout << v[0] << endl; 16 cout << v.front() << endl; 17 cout << *(v.begin()) << endl; 18 vector<int> v1; 19 try { 20 if (v1.begin() ==v1.end()) 21 throw out_of_range("error"); 22 v1.at(0); 23 } 24 catch (out_of_range err) { 25 cout << err.what() << endl; 26 } 27 system("pause"); 28 return 0; 29 }
浙公网安备 33010602011771号