i have written this program and made 3 constructors in the class and i want to call them in the main and i cant can any one help me and tell me how could i call them in the main
The default constructor makes no sense. You are using uninitialized variables to initialize the values.
1 2 3 4 5 6 7 8 9 10 11 12 13 14
Triangle :: Triangle ()
{
// wrong. They aren't initialized you have no idea what you are assigning
float firstSide , secondSide , thirdSide ;
side1 = firstSide ;
side2 = secondSide ;
side3 = thirdSide ;
}
// do this instead so that the sides are default initialized to zero.
Triangle :: Triangle () : side1(), side2(), side3()
{
}
Define "work". What do you expect it to do? It simply zero initializes the attributes of the class. What else could it do? if you want it to do something different put numbers within the parens to give the values whatever default values you wish. As it is currently written, it does exactly what it was written to do.