Thread: Is something wrong with this class

  1. #1
    Registered User
    Join Date
    Jul 2014
    Posts
    41

    Is something wrong with this class

    Iam trying to declare a class with a vector that is initialized as follows:
    Code:
    #include<vector>
    class S
    {
    	std::vector<int> v = { 1, 2, 3, 4, 5, 6, 7 };
    };
    int main()
    {
    
    
    }
    Is something wrong with the class S ?
    Last edited by V8cTor; 07-17-2015 at 02:35 PM.

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    3,445
    Quote Originally Posted by V8cTor View Post
    Is something wrong with the class S ?
    What does your compiler tell you?
    What can this strange device be?
    When I touch it, it gives forth a sound
    It's got wires that vibrate and give music
    What can this thing be that I found?

  3. #3
    Registered User
    Join Date
    Jul 2014
    Posts
    41
    when i try to build it, it says:
    error C2661: 'std::vector<int,std::allocator<_Ty>>::vector' : no overloaded function takes 7 arguments

  4. #4
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by V8cTor
    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").
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. trying to learn class templates what am i doing wrong
    By c++noob145 in forum C++ Programming
    Replies: 1
    Last Post: 04-25-2013, 08:03 PM
  2. wrong ELF class: ELFCLASS64
    By noviC in forum C Programming
    Replies: 22
    Last Post: 03-31-2009, 03:41 AM
  3. What is wrong with this class?
    By BKurosawa in forum C++ Programming
    Replies: 3
    Last Post: 08-09-2007, 05:15 PM
  4. Getting wrong output from a class
    By orikon in forum C++ Programming
    Replies: 11
    Last Post: 11-18-2005, 07:58 PM
  5. Is there anything wrong with this class prototype
    By Silvercord in forum C++ Programming
    Replies: 4
    Last Post: 02-05-2003, 08:25 PM