[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++

2 / 187

What is parameterized constructors, Give example?

Answer:

It may be necessary to initialize the various data elements of different objects with different values when they are created.
C++ permits us to achieve this objective by passing an argument to the constructor function when the objects are created. The constructors that can take arguments are called parameterized constructors.

Eg:
Class A
{
int m,n;
public:
A(int x,int y); //parameterized constructor
………..
………..
};
A : : A(int x,int y)
{
m=x;
n=y;
}

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.