fork download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. class Point {
  5.  
  6. private:
  7. T px, py;
  8.  
  9. public:
  10. Point(T x, T y): px(x), py(y) {
  11. std::cout << "created " << x << ":" << y <<std::endl;
  12. };
  13. T x() const { return px; };
  14. T y() const { return py; };
  15.  
  16. };
  17.  
  18. class PointWorld : public Point<double> {
  19. using Point::Point;
  20. };
  21.  
  22. class PointScreen: public Point<int> {
  23. using Point::Point;
  24. };
  25.  
  26.  
  27. int main() {
  28.  
  29. std::cout << PointScreen(100, 100).x() << std::endl;
  30.  
  31. return 0;
  32.  
  33. }
  34.  
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
created 100:100
100