Computer Science, asked by rohit123425, 11 months ago

write a C plus plus program to define a class a product having the data membership period ID period name of freed present accept and display data for three product using the constructor overloading​

Answers

Answered by shashikantkumar2758
0

Answer:

A constructor is a special type of member function that initialises an object automatically when it is created.

Compiler identifies a given member function is a constructor by its name and the return type.

Constructor has the same name as that of the class and it does not have any return type. Also, the constructor is always public.

Above program shows a constructor is defined without a return type and the same.

In the above pseudo code, temporary.

When an object of class temporary is created, the constructor is called automatically, and x is initialized to 5 and y is initialized to 5.5.

You can also initialise the data members inside the constructor's body as below. However, this method is not preferred.

Similar questions