G++ 版本问题

来源:互联网 发布:svn linux登录 编辑:程序博客网 时间:2024/06/06 02:27
请按 ENTER 或其它命令继续
ReverseofString.cpp: In member function ‘std::string Solution::reveseVowels(std::string)’:
ReverseofString.cpp:10:14: warning: extended initializer lists only available with -std=c++11 or -std=gnu++11 [enabled by default]
    set<char> hash1{'a','e','i','o','u','A','E','I','O','U'};
              ^
ReverseofString.cpp:10:59: error: in C++98 ‘hash1’ must be initialized by constructor, not by ‘{...}’
    set<char> hash1{'a','e','i','o','u','A','E','I','O','U'};
                                                           ^
ReverseofString.cpp:10:59: error: no matching function for call to ‘std::set<char>::set(<brace-enclosed initializer list>)’
ReverseofString.cpp:10:59: note: candidates are:
In file included from /usr/include/c++/4.8/set:61:0,
                 from ReverseofString.cpp:3:
/usr/include/c++/4.8/bits/stl_set.h:193:7: note: std::set<_Key, _Compare, _Alloc>::set(const std::set<_Key, _Compare, _Alloc>&) [with _Key = char; _Compare = std::less<char>; _Alloc = std::allocator<char>]
       set(const set& __x)
       ^
/usr/include/c++/4.8/bits/stl_set.h:193:7: note:   candidate expects 1 argument, 10 provided
/usr/include/c++/4.8/bits/stl_set.h:180:2: note: template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator, const _Compare&, const allocator_type&)
  set(_InputIterator __first, _InputIterator __last,
  ^
/usr/include/c++/4.8/bits/stl_set.h:180:2: note:   template argument deduction/substitution failed:
ReverseofString.cpp:10:59: note:   cannot convert ‘'i'’ (type ‘char’) to type ‘const std::less<char>&’
    set<char> hash1{'a','e','i','o','u','A','E','I','O','U'};
                                                           ^
In file included from /usr/include/c++/4.8/set:61:0,
                 from ReverseofString.cpp:3:
/usr/include/c++/4.8/bits/stl_set.h:163:2: note: template<class _InputIterator> std::set<_Key, _Compare, _Alloc>::set(_InputIterator, _InputIterator)
  set(_InputIterator __first, _InputIterator __last)
  ^
/usr/include/c++/4.8/bits/stl_set.h:163:2: note:   template argument deduction/substitution failed:
ReverseofString.cpp:10:59: note:   candidate expects 2 arguments, 10 provided
    set<char> hash1{'a','e','i','o','u','A','E','I','O','U'};
                                                           ^
In file included from /usr/include/c++/4.8/set:61:0,
                 from ReverseofString.cpp:3:
/usr/include/c++/4.8/bits/stl_set.h:148:7: note: std::set<_Key, _Compare, _Alloc>::set(const _Compare&, const allocator_type&) [with _Key = char; _Compare = std::less<char>; _Alloc = std::allocator<char>; std::set<_Key, _Compare, _Alloc>::allocator_type = std::allocator<char>]
       set(const _Compare& __comp,
       ^
/usr/include/c++/4.8/bits/stl_set.h:148:7: note:   candidate expects 2 arguments, 10 provided
/usr/include/c++/4.8/bits/stl_set.h:139:7: note: std::set<_Key, _Compare, _Alloc>::set() [with _Key = char; _Compare = std::less<char>; _Alloc = std::allocator<char>]
       set()
       ^
/usr/include/c++/4.8/bits/stl_set.h:139:7: note:   candidate expects 0 arguments, 10 provided



出现上述错误在编译C++时加上with -std=c++11 or -std=gnu++11 

这个是因为编译器版本的问题

如下编译



g++ removeDupLe.cpp -o removeDupLe -std=gnu++11
./removeDupLe


0 0
原创粉丝点击