Spread the post

Constructor with default arguments in c++

There are possible to give default argument of constructors of class.
Example

Program for Constructor with default arguments.

Output

Note that obj1 have not given project marks. then it will get default value. this default value can be modified by any of number. if given value of parameter then will be not applicable this default values (case 2).

Another example : Program for Constructor with two default arguments.

Output

Note that not possible to give parameter 4 and use to default parameter 3.

Spread the post

Recommended Posts: