fork download
  1. #include <string>
  2. #include <iostream>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. template<typename Second>
  8. class myPair: public pair<int,Second>
  9. {
  10. public:
  11. myPair(const Second& s = Second(), int j = 0)
  12. :pair<int,Second>(j,s)
  13. {}
  14.  
  15. void out() const
  16. { cout
  17. << "(" << this->first
  18. << ":" << this->second << ")\n";
  19. }
  20.  
  21. };
  22.  
  23.  
  24. int main(int argc, const char * argv[])
  25. {
  26. myPair<double> d(3.1415926);
  27. myPair<string> s("Hello",3);
  28.  
  29. d.out();
  30. s.out();
  31.  
  32. }
  33.  
  34.  
Success #stdin #stdout 0s 4380KB
stdin
Standard input is empty
stdout
(0:3.14159)
(3:Hello)