Using Uniform Initialization to Construct a vector
#include <iostream> #include <vector> using namespace std; int main() { using MyVector = vector<int>; MyVector vectorA( 1 ); cout << vectorA.size() << " " << vectorA[0] << endl; MyVector vectorB( 1, 10 ); cout << vectorB.size() << " " << vectorB[0] << endl; MyVector vectorC{ 1, 10 }; cout << vectorC.size() << " " << vectorC[0] << endl; return 0; }
1.使用Uniform Initialization可以使得初始化比较方便。
2.using的使用也比较陌生
时间: 2024-12-29 11:25:04