[Updated] Goldman Sachs Aptitude Test Questions and Answers
Practice List of TCS Digital Coding Questions !!!
Take 50+ FREE!! Online Data Interpretation Mock test to crack any Exams.
Technical Discussion :: C++

80 / 187

What is default argument constructor?

Answer:

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     
Report    

Post Your Reply Here:

Alert me
q4i-reply-your-answer

Report Error

Please Login First Click Here

Most Popular Qs.