fork(1) download
  1. #include <iostream>
  2. #include <cstring>
  3. #include <cstdlib>
  4. using namespace std;
  5. // шаблон функции printArray
  6. template <typename T>
  7. void plus(const T* num1,const T* num2){
  8. cout<<num1+num2;
  9. cout<<endl;
  10. }
  11. template <typename T>
  12. void cintype(const T* num1,const T* num2){
  13. cin>>num1;
  14. cin>>num2;
  15. }
  16.  
  17. int main()
  18. { template <typename T>
  19. const T* a;
  20. const T* b;
  21. cintype(a,b);
  22. plus(a,b)
  23.  
  24. return 0;
  25. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
5 6
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:18:3: error: a template declaration cannot appear at block scope
 { template <typename T>
   ^~~~~~~~
prog.cpp:21:10: error: ‘a’ was not declared in this scope
  cintype(a,b);
          ^
prog.cpp:21:12: error: ‘b’ was not declared in this scope
  cintype(a,b);
            ^
prog.cpp:22:2: error: reference to ‘plus’ is ambiguous
  plus(a,b)
  ^~~~
prog.cpp:7:6: note: candidates are: template<class T> void plus(const T*, const 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;
            ^~~~
stdout
Standard output is empty