Computer Science, asked by ekta2105, 1 year ago

explain multiple constructor in class​

Answers

Answered by glckin
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