[Solved] C++ : write a triangle class using point class [closed]


It won’t work because the triangle constructor will attempt to default construct its point members before assigning to them, but point doesn’t have a default constructor. This is because you provide only a point constructor that takes 2 arguments, so the defaulted default constructor is deleted.

Instead, you should use a member initialization list to initialise the points:

dreieck(point varp1, point varp2, point varp3)
  : p1(varp1), p2(varp2), p3(varp3)
{ }

This initialises each of the members p1, p2, and p3 with the arguments varp1, varp2, and varp3 respectively, therefore avoiding the default construction.

4

solved C++ : write a triangle class using point class [closed]