fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template <class x>
  5. class p{
  6. public:
  7. x setVal(x i);
  8. };
  9.  
  10. template <class x>
  11. x p::setVal(x i){
  12. return i*i;
  13. }
  14.  
  15. int main(){
  16. p<int> obj;
  17. p<double> obj2;
  18. cout << " RESULTADO COM INT " << obj.setVal(8);
  19. cout << " RESULTADO COM DOUBLE " << obj2.setVal(7.4);
  20. cin.get();
  21. return 0;
  22. }
  23.  
  24.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:11:3: error: 'template<class x> class p' used without template parameters
 x p::setVal(x i){
   ^
stdout
Standard output is empty