fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T>
  5. class Rect
  6. {
  7. using val_t = T;
  8. public:
  9. Rect(const val_t x0, const val_t y0, const val_t x, const val_t y)
  10. : p0{ x0, y0 }, p{ x, y } {}
  11.  
  12. val_t left() const { return p0.x; }
  13. val_t bottom() const { return p0.y; }
  14. val_t right() const { return p.x; }
  15. val_t top() const { return p.y; }
  16.  
  17. private:
  18. struct point
  19. {
  20. val_t x = 0;
  21. val_t y = 0;
  22. } p0, p;
  23. };
  24.  
  25. int main() {
  26. Rect<int> r(0, 0, 1, 1);
  27.  
  28. decltype(r)::val_t x = r.left();
  29.  
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:28:15: error: ‘using val_t = int’ is private within this context
  decltype(r)::val_t x = r.left();
               ^~~~~
prog.cpp:7:17: note: declared private here
  using val_t = T;
                 ^
stdout
Standard output is empty