Take FREE!! Online Cocubes Mock Test to Crack various Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
Take 30+ FREE!! Online Arithmetic Aptitude Mock test to crack any Exams.
Technical Discussion :: C++

80 / 184

What is default argument constructor?


It is possible to define constructors with default arguments. for example, the constructor complex( ) can be declared as follows:

Complex(float real, float imag=0)
The default value of the argument imag is zero.then the statement
Complex c(5.0);
Assigns the value 5.0 to the real variable and 0.0 to imag (by default). However, the statement
Complex c(2.0,3.0);
Assigns 2.0 to real and 3.0 to imag. The actual parameter, when specified, overrides the default value. As pointed out earlier, the missing arguments must be the trailing ones.

Asked In ::

Post Your Answer Here:

Rate This: +0 -0     

Post Your Reply Here:

Alert me

Report Error

Please Login First Click Here

Most Popular Qs.