fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4. using namespace std;
  5. // шаблон функции printArray
  6. template <typename T>
  7. T a,b;
  8. template <typename T>
  9.  
  10. void plus(const T num1,const T num2){
  11. cout<<num1+num2;
  12. cout<<endl;
  13. }
  14. template <typename T>
  15. void cintype(const T num1,const T num2){
  16. cin>>num1;
  17. cin>>num2;
  18. }
  19.  
  20. int main()
  21. {
  22. cintype(b,a);
  23. plus(a,b)
  24.  
  25. return 0;
  26. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 6
compilation info
prog.cpp:7:4: error: expected ‘;’ before ‘,’ token
 T a,b;
    ^
prog.cpp: In function ‘int main()’:
prog.cpp:22:10: error: ‘b’ was not declared in this scope
  cintype(b,a);
          ^
prog.cpp:22:13: error: missing template arguments before ‘)’ token
  cintype(b,a);
             ^
prog.cpp:23:2: error: reference to ‘plus’ is ambiguous
  plus(a,b)
  ^~~~
prog.cpp:10:6: note: candidates are: template<class T> void plus(T, T)
 void plus(const T num1,const T num2){
      ^~~~
In file included from /usr/include/c++/6/string:48:0,
                 from /usr/include/c++/6/bits/locale_classes.h:40,
                 from /usr/include/c++/6/bits/ios_base.h:41,
                 from /usr/include/c++/6/ios:42,
                 from /usr/include/c++/6/ostream:38,
                 from /usr/include/c++/6/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/6/bits/stl_function.h:147:12: note:                 template<class _Tp> struct std::plus
     struct plus;
            ^~~~
prog.cpp:23:8: error: missing template arguments before ‘,’ token
  plus(a,b)
        ^
stdout
Standard output is empty