explain multiple constructor in class
Answers
Answered by
1
Answer:
Constructors are methods that creates an instance object of a class and inicializes and sets variables inside. Multiple constructors are handy in cases you get different input that initilize the object different
Explanation:
class Shape {
int width;
int height;
int area;
Shape(int radius): width(radius*2), height(radius*2), area(radius*radius*3,14) {};
Shape(int w, int h): width(w), height(h), area(w*h) {}
}
Similar questions