fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Point
  5. {
  6. Point(int x, int y);
  7. };
  8.  
  9. class Shape { // deals with color and style, and holds sequence of lines
  10. protected:
  11. Shape() { }
  12. Shape(initializer_list<Point> lst); // add() the Points to this Shape
  13.  
  14. void add(Point p);
  15. };
  16.  
  17. struct Open_polyline : Shape { // open sequence of lines
  18. using Shape::Shape; // use Shape’s constructors (§A.16)
  19. void add(Point p) { Shape::add(p); }
  20. };
  21.  
  22. Open_polyline opl = {
  23. Point{100,100}, Point{150,200}, Point{250,250}, Point{300,200}
  24. };
  25.  
  26. int main() {
  27. // your code goes here
  28. return 0;
  29. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:24:5: error: ‘Shape::Shape(std::initializer_list<Point>)’ is protected within this context
     };
     ^
prog.cpp:12:2: note: declared protected here
  Shape(initializer_list<Point> lst);  // add() the Points to this Shape
  ^~~~~
stdout
Standard output is empty