Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'  next -- Keyboard shortcut: 'n'          templates/vers2-f14/prog1-compilation - Compiler errors for the program from above - typical for compilation of template instances with errors.Lecture 5 - slide 33 : 40
Program 5

$ g++ prog1.cc point.o -std=c++11
prog1.cc: In function ‘int main()’:
prog1.cc:22:3: error: ‘string’ was not declared in this scope
   string s{};
   ^
prog1.cc:22:3: note: suggested alternative:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iosfwd:39:0,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ios:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ostream:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iostream:39,
                 from prog1.cc:1:
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/stringfwd.h:62:33: note:   ‘std::string’
   typedef basic_string<char>    string;
                                 ^
In file included from prog1.cc:3:0:
point.cc: In instantiation of ‘Point<C>::Point() [with C = std::basic_string<char>]’:
prog1.cc:23:22:   required from here
point.cc:11:54: error: no matching function for call to ‘std::basic_string<char>::basic_string(double)’
 template<typename C> Point<C>::Point(): x(0.0), y(0.0){
                                                      ^
point.cc:11:54: note: candidates are:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/string:52:0,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/locale_classes.h:40,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/ios_base.h:41,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ios:42,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ostream:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iostream:39,
                 from prog1.cc:1:
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:540:9: note: template<class _InputIterator> std::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&)
         basic_string(_InputIterator __beg, _InputIterator __end,
         ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:540:9: note:   template argument deduction/substitution failed:
In file included from prog1.cc:3:0:
point.cc:11:54: note:   candidate expects 3 arguments, 1 provided
 template<typename C> Point<C>::Point(): x(0.0), y(0.0){
                                                      ^
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/string:52:0,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/locale_classes.h:40,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/ios_base.h:41,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ios:42,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ostream:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iostream:39,
                 from prog1.cc:1:
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:530:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:530:7: note:   no known conversion for argument 1 from ‘double’ to ‘std::initializer_list<char>’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:512:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(basic_string&& __str)
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:512:7: note:   no known conversion for argument 1 from ‘double’ to ‘std::basic_string<char>&&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:502:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:502:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:495:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:495:7: note:   no known conversion for argument 1 from ‘double’ to ‘const char*’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:488:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const _CharT* __s, size_type __n,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:488:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:476:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:476:7: note:   candidate expects 4 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:467:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:467:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:460:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const basic_string& __str);
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:460:7: note:   no known conversion for argument 1 from ‘double’ to ‘const std::basic_string<char>&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:453:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _Alloc& __a);
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:453:7: note:   no known conversion for argument 1 from ‘double’ to ‘const std::allocator<char>&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:442:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string()
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:442:7: note:   candidate expects 0 arguments, 1 provided
In file included from prog1.cc:3:0:
point.cc:11:54: error: no matching function for call to ‘std::basic_string<char>::basic_string(double)’
 template<typename C> Point<C>::Point(): x(0.0), y(0.0){
                                                      ^
point.cc:11:54: note: candidates are:
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/string:52:0,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/locale_classes.h:40,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/ios_base.h:41,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ios:42,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ostream:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iostream:39,
                 from prog1.cc:1:
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:540:9: note: template<class _InputIterator> std::basic_string<_CharT, _Traits, _Alloc>::basic_string(_InputIterator, _InputIterator, const _Alloc&)
         basic_string(_InputIterator __beg, _InputIterator __end,
         ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:540:9: note:   template argument deduction/substitution failed:
In file included from prog1.cc:3:0:
point.cc:11:54: note:   candidate expects 3 arguments, 1 provided
 template<typename C> Point<C>::Point(): x(0.0), y(0.0){
                                                      ^
In file included from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/string:52:0,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/locale_classes.h:40,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/ios_base.h:41,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ios:42,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/ostream:38,
                 from /usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/iostream:39,
                 from prog1.cc:1:
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:530:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::initializer_list<_Tp>, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(initializer_list<_CharT> __l, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:530:7: note:   no known conversion for argument 1 from ‘double’ to ‘std::initializer_list<char>’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:512:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>&&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(basic_string&& __str)
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:512:7: note:   no known conversion for argument 1 from ‘double’ to ‘std::basic_string<char>&&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:502:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(std::basic_string<_CharT, _Traits, _Alloc>::size_type, _CharT, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(size_type __n, _CharT __c, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:502:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:495:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _CharT* __s, const _Alloc& __a = _Alloc());
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:495:7: note:   no known conversion for argument 1 from ‘double’ to ‘const char*’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:488:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _CharT*, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const _CharT* __s, size_type __n,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:488:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:476:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type, const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:476:7: note:   candidate expects 4 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:467:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&, std::basic_string<_CharT, _Traits, _Alloc>::size_type, std::basic_string<_CharT, _Traits, _Alloc>::size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; std::basic_string<_CharT, _Traits, _Alloc>::size_type = unsigned int]
       basic_string(const basic_string& __str, size_type __pos,
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:467:7: note:   candidate expects 3 arguments, 1 provided
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:460:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const std::basic_string<_CharT, _Traits, _Alloc>&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const basic_string& __str);
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:460:7: note:   no known conversion for argument 1 from ‘double’ to ‘const std::basic_string<char>&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:453:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string(const _Alloc&) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string(const _Alloc& __a);
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:453:7: note:   no known conversion for argument 1 from ‘double’ to ‘const std::allocator<char>&’
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:442:7: note: std::basic_string<_CharT, _Traits, _Alloc>::basic_string() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>]
       basic_string()
       ^
/usr/lib/gcc/i686-pc-cygwin/4.9.2/include/c++/bits/basic_string.h:442:7: note:   candidate expects 0 arguments, 1 provided
$