error C2955: 'vector' : use of class template requires template argument list
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: error C2955: 'vector' : use of class template requires template argument list

  1. #1
    Join Date
    Nov 2008
    Posts
    26

    error C2955: 'vector' : use of class template requires template argument list

    hi everybody : )

    I am trying to create a music sampling application with VC++ 6.0 and SDL, but I have a strange issue in designing one of the classes. here's my header file code:

    Code:
    #include <string>
    #include <vector>
    
    using namespace std;
    
    
    class Channel
    {
    public:
    
    	Channel(string wav, unsigned buttonsNumber);
    
    	//function declarations....
    
    
    private:
    
    	//..data members
    	vector<bool> buttons;
    
    };
    
    /*...function definitions..*/
    
    Channel::Channel(string wav, unsigned buttonsNumber)
    {
    	wave = wav;
    	buttons.resize(buttonsNumber,false);
    }
    when I try to compile it I get the following error:
    c:\program files\microsoft visual studio\vc98\include\ik_vec3d.h(255) : error C2955: 'vector' : use of class template requires template argument list

    I must be missing something, because I think that the template argument list is : <bool>, please correct me if i'm wrong..

    ---

    I was also wondering if someone would suggest an article, link, whatever, which can help me with the following:

    I need my application to open a windows folder and create a vector<string> of all the files inside that folder which are "*.wav", that is - all the wav files, how can I do that, are there any STL libraries for that purpose?

    thanks in advance : )

    I think it's great of someone to take its time to help others with their issues..thats awesome.. i should also do that when my brain becomes bigger and smarter.. : )

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: error C2955: 'vector' : use of class template requires template argument list

    I guess you could try calling it std::vector<bool>....not a good idea to put a using statement in a header anyway.

    You should be aware that vector<bool> is not a typical vector---it uses a packed, 1-bit-per-element representation. Maybe this is fine for you, maybe not, but you should be aware of it.

    I need my application to open a windows folder and create a vector<string> of all the files inside that folder which are "*.wav", that is - all the wav files, how can I do that, are there any STL libraries for that purpose?
    The standard library doesn't contain any file system understanding at present, although Boost.Filesystem is being considered for inclusion in TR2. You can either make use of Boost.Filesystem to do this, or you can use WinAPI directly; it's not that hard in this case (see documentation on FindFirstFile and FindNextFile).

  3. #3
    Join Date
    Nov 2008
    Posts
    26

    Re: error C2955: 'vector' : use of class template requires template argument list

    thanks a lot, removed the using declaration and added the std:: prefix and now it compiles.. didn't know that using declarations in a .h file is not a good idea..

    what you mentioned about vector<bool>.. does the fact that it uses 1 bit-per element matter when using it, i mean what should i be aware of when using it?
    C++ Primer 4th, my Holy C++ Bible says that library bitset type should be used for keeping flag info like the one i need, but i don't have a lot of time right now..

    i should also check out boost when i have time, a lot of people are recommending it.. thanks again : )
    Last edited by seventhirty; June 5th, 2009 at 08:12 AM.

  4. #4
    Join Date
    Aug 2000
    Location
    West Virginia
    Posts
    7,646

    Re: error C2955: 'vector' : use of class template requires template argument list

    1) Your code compiles OK for me (except the wave = wav; line). There
    must be something else.

    2) For getting list of wav files in a folder. See the FAQ:

    http://www.codeguru.com/forum/showthread.php?t=312461

  5. #5
    Join Date
    Apr 1999
    Posts
    27,446

    Re: error C2955: 'vector' : use of class template requires template argument list

    Quote Originally Posted by seventhirty View Post
    what you mentioned about vector<bool>.. does the fact that it uses 1 bit-per element matter when using it, i mean what should i be aware of when using it?
    Change it to std::deque<bool>, and you won't have to change any of your other code (unless you're using the vector<bool> as a "true" array, i.e. you're assuming that your vector<bool> stores its data contiguously).

    Regards,

    Paul McKenzie

  6. #6
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,891

    Re: error C2955: 'vector' : use of class template requires template argument list

    Quote Originally Posted by seventhirty View Post
    what you mentioned about vector<bool>.. does the fact that it uses 1 bit-per element matter when using it, i mean what should i be aware of when using it?
    Off the top of my head, all I can think of is that unlike other vectors, &vec[0] doesn't have type bool*, and you can't take a bool& (reference) to any of the elements.

    C++ Primer 4th, my Holy C++ Bible says that library bitset type should be used for keeping flag info like the one i need, but i don't have a lot of time right now..
    std::bitset should be used if you know the number of flags you'll need at compile time. If you don't, you can think of std::vector<bool> as a dynamic-sized bitset. It even has a couple of methods that other vectors don't.
    Last edited by Lindley; June 5th, 2009 at 09:43 AM.

  7. #7
    Join Date
    Jan 2006
    Location
    Singapore
    Posts
    6,391

    Re: error C2955: 'vector' : use of class template requires template argument list

    Quote Originally Posted by Lindley
    std::bitset should be used if you know the number of flags you'll need at compile time. If you don't, you can think of std::vector<bool> as a dynamic-sized bitset. It even has a couple of methods that other vectors don't.
    I feel that boost::dynamic_bitset is more appropriate than std::vector<bool> when you need a dynamically sized version of std::bitset. However, I do not know whether Boost's current implementation plays well with the pre-standard MSVC6.
    C + C++ Compiler: MinGW port of GCC
    Build + Version Control System: SCons + Bazaar

    Look up a C/C++ Reference and learn How To Ask Questions The Smart Way
    Kindly rate my posts if you found them useful

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center