Map default Value compilation error in g++

This is a discussion on Map default Value compilation error in g++ within the C++ Programming forums, part of the General Programming Boards category; Following code gives a compilation error when compiled with g++ Code: #include <map> using namespace std; class G { //void ...

  1. #1
    Registered User
    Join Date
    Oct 2010
    Posts
    10

    Map default Value compilation error in g++

    Following code gives a compilation error when compiled with g++

    Code:
      
    #include <map>
    
    using namespace std;
    
             class G
          {
              //void fun(int , const std::map<std::string, bool> &  some_attributes = std::map<std::string, bool>());
              void fun(int , const map<string, bool>&  some_attributes = std::map<std::string, bool>());
          };
    Error is
    ======
    test.cxx:7: error: expected `,' or `...' before '>' token
    test.cxx:7: error: wrong number of template arguments (1, should be 4)
    /usr/lib/gcc/i386-redhat-linux/3.4.6/../../../../include/c++/3.4.6/bits/stl_map.h:92: error: provided for `template<class _Key, class _Tp, class _Compare, class _Alloc> class std::map'
    test.cxx:7: error: default argument missing for parameter 3 of `void G::fun(int, const std::map<std::string, bool, std::less<std::string>, std::allocator<std:air<const std::string, bool> > >&, bool)'
    =======


    Any one has any idea how to get rid of the error ?

  2. #2
    Registered User
    Join Date
    Oct 2006
    Posts
    2,305
    what version of linux are you running? it looks like the version of g++ (3.4.6) that you are running is very old. it compiles just fine on g++ 4.5.0.

  3. #3
    Registered User
    Join Date
    Oct 2010
    Posts
    10
    thanks, will try with that.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 47
    Last Post: 07-13-2010, 07:22 PM
  2. Adding a Map to a program
    By Shogun32 in forum C++ Programming
    Replies: 1
    Last Post: 05-04-2009, 09:42 AM
  3. Polynomials and ADT's
    By Emeighty in forum C++ Programming
    Replies: 20
    Last Post: 08-19-2008, 08:32 AM
  4. Utilizing another compiled program for a task.
    By kotoroshinoto in forum C Programming
    Replies: 6
    Last Post: 06-03-2008, 01:43 PM
  5. Creating a map engine.
    By suzakugaiden in forum Game Programming
    Replies: 11
    Last Post: 06-21-2005, 05:06 AM

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