fork download
  1. #include <iostream>
  2.  
  3. template<class T1,class T2>
  4. const T2& GetSecond(const T1& A, const T2& B){
  5. return B;
  6. }
  7. template<class T1,class T2>
  8. T2& GetSecond(T1& A,T2& B){
  9. return B;
  10. }
  11.  
  12. int main(){
  13. char A = 1;
  14. int B = 2;
  15.  
  16.  
  17. std::cout << "Answer:" << GetSecond(A, B) << std::endl;
  18. std::cout << "Answer:" << GetSecond(1, 2) << std::endl;
  19. std::cout << "Answer:" << GetSecond(1, B) << std::endl;
  20. std::cout << "Answer:" << GetSecond(A, 3) << std::endl;
  21. return 0;
  22. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
Answer:2
Answer:2
Answer:2
Answer:3