class template arg is a class template arg is a...

This is a discussion on class template arg is a class template arg is a... within the C++ Programming forums, part of the General Programming Boards category; I'm writing a generic Vector class (vector as in linear algebra not STL std::vector). I want to use STL std::vector ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    1

    class template arg is a class template arg is a...

    I'm writing a generic Vector class (vector as in linear algebra not STL std::vector). I want to use STL std::vector as the internal container.

    Code:
    #include <vector>
    
    template < class T > // specifies what types the std::vector will store
    class MyClass
    {
        public:
            MyClass(std::vector<T>::iterator begin, std::vector<T>::iterator end)
            {
                // blah
            }
            //...
        private:
            std::vector<T> m_data;
    };
    With g++ 4.1.2 I get the following compiler errors:

    Code:
    vec.h: error: expected `)' before ‘begin’
    I've tried using typedefs like:

    Code:
    typedef std::vector<T> Container;
    typedef Container::iterator Iterator;  // or typedef std::vector<T>::iterator Iterator;
    with no luck (nor did I expect it.)

    Any help please?
    Thank you

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,659
    You need this:

    >> MyClass(typename std::vector<T>::iterator begin, typename std::vector<T>::iterator end)

    gg

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. linker error
    By tasha302 in forum C++ Programming
    Replies: 3
    Last Post: 12-13-2006, 11:00 PM
  2. template class default constructor problem
    By kocika73 in forum C++ Programming
    Replies: 3
    Last Post: 04-22-2006, 09:42 PM
  3. Instantiating a template class
    By NullS in forum C++ Programming
    Replies: 11
    Last Post: 02-23-2005, 09:04 AM
  4. Function template in Class template?
    By Aidman in forum C++ Programming
    Replies: 3
    Last Post: 10-28-2003, 08:50 AM
  5. oh me oh my hash maps up the wazoo
    By DarkDays in forum C++ Programming
    Replies: 5
    Last Post: 11-30-2001, 11:54 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21