fork download
  1. class Vector
  2. {
  3. float x;
  4. float y;
  5.  
  6. public:
  7. Vector(float x, float y) : x(x), y(y) {}
  8. Vector& operator = (const Vector& v) { x = v.x; y = v.y; return *this; }
  9. //Vector(Vector&&) = default;
  10. };
  11.  
  12.  
  13. class Rect
  14. {
  15. public:
  16. union {
  17. struct {
  18. Vector p1, p2;
  19. } ;
  20.  
  21. struct {
  22. float p1x, p1y, p2x, p2y;
  23. } ;
  24. } ;
  25.  
  26.  
  27. Rect() : p1(0, 0), p2(0, 0) {}
  28. Rect(Vector& p1, Vector& p2) : p1(p1), p2(p2) {}
  29.  
  30. Rect& operator=(const Rect& other) {
  31. p1 = other.p1 ;
  32. p2 = other.p2 ;
  33. return *this ;
  34. }
  35.  
  36. /*Rect(const Rect&) = default;
  37.   Rect& operator=(const Rect&) = default;
  38.   Rect& operator=(Rect&&) = default;
  39.   Rect(Rect&&) = default;*/
  40. };
  41.  
  42.  
  43. int main()
  44. {
  45. Rect test = Rect();
  46. test = Rect();
  47. return 0;
  48. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:18:20: error: member 'Vector Rect::<anonymous union>::<anonymous struct>::p1' with constructor not allowed in anonymous aggregate
             Vector p1, p2;
                    ^
prog.cpp:18:20: error: member 'Vector Rect::<anonymous union>::<anonymous struct>::p1' with copy assignment operator not allowed in anonymous aggregate
prog.cpp:18:24: error: member 'Vector Rect::<anonymous union>::<anonymous struct>::p2' with constructor not allowed in anonymous aggregate
             Vector p1, p2;
                        ^
prog.cpp:18:24: error: member 'Vector Rect::<anonymous union>::<anonymous struct>::p2' with copy assignment operator not allowed in anonymous aggregate
stdout
Standard output is empty