Sunday, 1 September 2013

C++ 11 initialization with auto

C++ 11 initialization with auto

In C++ 11, we're encouraged to use auto for variable type,
does this also apply when initializing type like class and vector?
I mean should we write the following:
auto a = 10;
auto b = MyClass();
auto c = vector<int>{1, 2, 3};
instead of:
auto a = 10;
MyClass b;
vector<int> c = {1, 2, 3};

No comments:

Post a Comment