May 2012
Intermediate to advanced
679 pages
16h 56m
English
It is possible to have a constructor with default arguments.. It means that if the constructor is defined with n parameters, we can invoke it with less than n arguments specified in the call.
If we define constructor for class Anyname as
Anyname ( para1,para2,para3,para4 =val4, … paran = valn);
where para1, para2 are symbolic representations of parameters, then we can invoke this constructor as Anyname(para1,para2,para3);
Let us take a concrete example.
Date(int d , int m , int y = 2002);
This construct has three parameters. Parameter number three is initialized with a value 2002. Now we can call the constructor in two possible ways.
The first constructor will initialize ...
Read now
Unlock full access