C++ 练习记录1--vector<T> 中T的初始化
//编译环境: vs2013 32位win8操作系统
#include <tuple>
#include <vector>
#include <iostream>
using std::cout;
using std::endl;
class A
{
int x = 0;
public:
A();
~A();
private:
};
A::A()
{
}
A::~A()
{
}
int main()
{
std::tuple<A, int, float> t;//这里会调用A()
std::vector<A> va(1); //这里会调用A()
std::list<A> va(1);//这里会调用A()
cout << std::get<1>(t) << endl;//0
cout << std::get<2>(t) << endl;//0
getchar();
return 0;
}
#include <tuple>
#include <vector>
#include <iostream>
using std::cout;
using std::endl;
class A
{
int x = 0;
public:
A();
~A();
private:
};
A::A()
{
}
A::~A()
{
}
int main()
{
std::tuple<A, int, float> t;//这里会调用A()
std::vector<A> va(1); //这里会调用A()
std::list<A> va(1);//这里会调用A()
cout << std::get<1>(t) << endl;//0
cout << std::get<2>(t) << endl;//0
getchar();
return 0;
}