fork download
  1. #include <iostream>
  2. template <typename T >
  3. void f(T a,int b,int c=3);
  4. template <typename T >
  5. void f(T a,int b=9,int c);
  6. int main()
  7. {
  8. f(3);
  9. f(3,6);
  10. f(3,6,9);
  11. return 0;
  12. }
  13. template <typename T >
  14. void f(T a,int b,int c)
  15. {
  16. std::cout<<a<<' '<<b<<' '<<c<<'\n';
  17. }
  18.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:5:6: error: default argument missing for parameter 3 of 'void f(T, int, int)'
 void f(T a,int b=9,int c);
      ^
prog.cpp:5:25: error: redeclaration of 'template<class T> void f(T, int, int)' may not have default arguments [-fpermissive]
 void f(T a,int b=9,int c);
                         ^
prog.cpp: In function 'int main()':
prog.cpp:8:5: error: no matching function for call to 'f(int)'
  f(3);
     ^
prog.cpp:3:6: note: candidate: template<class T> void f(T, int, int)
 void f(T a,int b,int c=3);
      ^
prog.cpp:3:6: note:   template argument deduction/substitution failed:
prog.cpp:8:5: note:   candidate expects 3 arguments, 1 provided
  f(3);
     ^
stdout
Standard output is empty