4.06 Types of Constructors in C++

Darshan University
Darshan University
6.1 هزار بار بازدید - 6 سال پیش - Default, parameterized and copy constructor
Default, parameterized and copy constructor with example programs.

A constructor is a block of code which is
- similar to a member function.
- has the same name as class name.
- called automatically when an object of a class created.
A default constructor is the one which invokes by default when an object of the class is created.
It is generally used to initialize the default value of the data members.
It is also called no argument constructor.
Constructors that can take arguments are called parameterized constructors.
Sometimes it is necessary to initialize the various data elements of different objects with different values when they are created.
We can achieve this objective by passing arguments to the constructor function when the objects are created.
A copy constructor is used to declare and initialize an object from another object using an object as an argument.
Constructor which accepts a reference to its own class as a parameter is called copy constructor.

GTU - Computer Engineering (CE) - Semester 4 - 2140703 - Object Oriented Programming with C++ - Concepts of C++ - Introduction to Object Oriented Programming

Object-Oriented Programming with C++ PPTs are available here: http://www.darshan.ac.in/DIET/CE/GTU-...

This video is recorded by Prof. Rupesh Vaishnav ([email protected], +91-9428037452) at Computer Engineering Department of Darshan Institute of Engineering & Technology, Rajkot as per GTU Syllabus.

Darshan Institute of Engineering & Technology, Rajkot is a leading institute offering undergraduate, graduate and postgraduate programs in engineering. The Institute is affiliated to the Gujarat Technological University (GTU) and approved by the AICTE, New Delhi.

Visit us: http://www.darshan.ac.in
Write us: [email protected]
Facebook: Facebook: DarshanInstitute.Official
Twitter: Twitter: darshan_inst
Instagram: Instagram: darshan_inst
6 سال پیش در تاریخ 1397/02/13 منتشر شده است.
6,187 بـار بازدید شده
... بیشتر