Take FREE!! Online Mettl Mock Test to Crack TechM and Other Companies Written Exams.
Get Off-Campus Placement Jobs Info !!!
TCS NQT Technical and Managerial Round Interview Questions
Technical Discussion :: C++

92 / 184

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.