Default Constructor-: A constructor that accepts no parameters is known as default constructor. If no constructor is defined then the compiler supplies a default constructor. student :: student() { rollno=0; marks=0.0; }Parameterized Constructor -: A constructor that receives arguments/parameters, is called parameterized constructor. student :: student(int r) { rollno=r; }Copy Constructor-: A constructor that initializes an object using values of another object passed to it as parameter, is called copy constructor. It creates the copy of the passed object. student :: student(student &t) { rollno = t.rollno; }There can be multiple constructors of the same class, provided they have different signatures.
C++
Topic: Constructors and destructors
What are types of Constructor ?
Browse random answers:
What are Class Constructors and destructors in C++ ?
What is the use of Constructor ?
What is the use of Destructors
What are Constructor and Destructor Order ?
What is virtual Destructors ?
Explain about overview of constructors and destructors (C++ only) ?
What are the restrictions apply to constructors and destructors?
What is virtual constructors/destructors?
What is a default constructor?
What is a conversion constructor?
Difference between a copy constructor and an assignment operator.
What is copy constructor?
How should a constructor handle a failure?
What are shallow and deep copy?
What are the restrictions apply to constructors and destructors?
Explain the order in which constructors are called when an object of a derived class is created.
Explain about parameterized Constructor ?
What are using Initialization Lists to Initialize Fields ?
what’s a virtual destructor and when is it needed?
Explain about overloading Constructors ?
Explain interfaces in C++ (Abstract Classes) ?
Explain about Designing Strategy ?
What are types of Constructor ?