Iam trying to declare a class with a vector that is initialized as follows:
Is something wrong with the class S ?Code:#include<vector> class S { std::vector<int> v = { 1, 2, 3, 4, 5, 6, 7 }; }; int main() { }
Iam trying to declare a class with a vector that is initialized as follows:
Is something wrong with the class S ?Code:#include<vector> class S { std::vector<int> v = { 1, 2, 3, 4, 5, 6, 7 }; }; int main() { }
Last edited by V8cTor; 07-17-2015 at 02:35 PM.
when i try to build it, it says:
error C2661: 'std::vector<int,std::allocator<_Ty>>::vector' : no overloaded function takes 7 arguments
It looks like you are compiling with MSVC. Checking this page on Support For C++11 Features, it looks like you need to upgrade to Visual Studio 2013 in order for the compiler to support the necessary features ("Non-static data member initializers" and "Initializer lists").Originally Posted by V8cTor
Look up a C++ Reference and learn How To Ask Questions The Smart WayOriginally Posted by Bjarne Stroustrup (2000-10-14)