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. void plus(const T num1,const T num2){
  9. cout<<num1+num2;
  10. cout<<endl;
  11. }
  12. template <typename T>
  13. void cintype(const T num1,const T num2){
  14. cin>>num1;
  15. cin>>num2;
  16. }
  17.  
  18. int main()
  19. {
  20. cintype(b,a);
  21. plus(a,b)
  22.  
  23. return 0;
  24. }
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:8:17: error: ‘T’ does not name a type
 void plus(const T num1,const T num2){
                 ^
prog.cpp:8:30: error: ‘T’ does not name a type
 void plus(const T num1,const T num2){
                              ^
prog.cpp: In function ‘int main()’:
prog.cpp:20:10: error: ‘b’ was not declared in this scope
  cintype(b,a);
          ^
prog.cpp:20:13: error: missing template arguments before ‘)’ token
  cintype(b,a);
             ^
prog.cpp:21:2: error: reference to ‘plus’ is ambiguous
  plus(a,b)
  ^~~~
prog.cpp:8:6: note: candidates are: void plus(int, int)
 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:21:8: error: missing template arguments before ‘,’ token
  plus(a,b)
        ^
stdout
Standard output is empty