Constructor overloading in C++

LearnByWatch 1,827 views 6 slides Nov 05, 2015
Slide 1
Slide 1 of 6
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6

About This Presentation

you will learn constructor overloading in c++


Slide Content

Constructor Overloading Yogendra Pal

At the end of this tutorial you will be able to Overload a constructor. Differentiate between initialized and uninitialized object. Identify overloaded functions from a given c++ program. Identify which function will execute on a call to overloaded function . Call a constructor explicitly and implicitly. www.learnbywatch.com | [email protected]

Constructor Overloading Creating more than one constructors for a c++ class. Signature of each constructor should be different. Allow to create both initialized and uninitialized objects. www.learnbywatch.com | [email protected]

Create an initialized object Uninitialized Object Time t; Time t = Time(); Member variables are not initialized. I nitialized Object Time t(04,02,1985); Time t = Time(04, 02, 1985 ); Member variables are initialized. www.learnbywatch.com | [email protected]

How to use Constructors? Two ways to initialize an object by using a constructor: An Explicit call to constructor: Time t1 = Time(12, 24, 10); An Implicit call to constructor: Time t1(12, 24, 10); Constructor is called whenever you create an object of a class. The constructor creates object. There is no object until the constructor finishes it’s work. You can’t call a constructor with an object. www.learnbywatch.com | [email protected]

Ask Q uestions to learn better Yogendra Pal www.learnbywatch.com | [email protected]