 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you the use of default and parameterize constructor in C++. Before starting, you can note my information. You can connect with me by following these details. You can download my app Techimus based on programming available on Google Play. You can search my channel on YouTube by my name Sanjay Gupta. You can open my channel and you can subscribe it where various programming related videos and playlists are available. You can improve your programming skills by watching these videos. Now coming on to the topic. You can see here a code is implemented which is having only default constructor implemented here. So first time demonstrating you the use of default constructor. Then I will be explaining how you can use parameterize constructor also. So first statement is header file inclusion. Then STD namespace is used. Then class complex is defined. Here R and I are attributes. Then in public section default constructor is defined. R is initializing by 15 and I is initializing with 10. Then read function which will display enter real and imaginary on console. Then values will be stored inside R and I using scene. Then next print function is defined which will display real and imaginary values on console. After termination of class I have created two objects C1 and C2. And after just after their creation I have printed them using print function call. So let's see what happens in case of default constructor. You can see both are printing same values 15, 10 and 15, 10. This is because we are using only default constructor. Now there is a question. Can we assign different values to different objects while they are created? Like a 5 and 10 in C1 and 10 and 20 in C2. Answer is yes with the help of parameterized constructor. Now I am defining a parameterized constructor. You can see its definition. It is receiving two arguments inside A and B. A is assigned into R and B is assigned into I. So this is parameterized constructor. Now I am creating two more objects C3. I am assigning 5 and 10 inside it. And C4 I am assigning 30 and 40 inside it. Similar to C1 and C2 I am first printing C3 and then printing C4. So C1 and C2 are initialized with default. So they will print 15 and 10. Whereas C3 and C4 are initialized with 5, 10 and 30, 40 respectively. So now I am executing this code. You can see the result. 15, 10, 15, 10 through C1 and C2. 5, 10 through C3 and 30, 40 through C4. So friends, if you want to initialize objects with different values, then you can prefer parameterized constructor in place of default constructor. And here I am implementing two constructors. One is default and second one is parameterized constructor. Name of both the constructors are same as class name. As you have to remember that if we are implementing more than one constructors in a class, then this concept is known as constructor overloading. It is similar to the function overloading concept which is available in C++. So whenever we want to implement constructor in class, we have to use same name as name of class. So if you define two constructors in a class, then their name must be same, but their argument should be different. So you can differentiate how a multiple constructor will be working in C++. Now I am also implementing one more parameterized constructor like this. This is also a parameterized constructor, but it is having only one argument. So this way I have implemented three constructors. Default, single parameterized and double parameterized constructor. This parameterized constructor A will be assigned into R and I will be initialized each time by 10. So it is mixture of parameterized and default. For R it is parameterized and for I it is default constructor. And I can call it by like this. So C3 is calling single parameterized constructor and C4 is calling double parameterized constructor. Now I am executing it. You can see the output this time C3 is printing 5 and 10 because I have initialized it with by 10. So this way I have implemented default and parameterized constructor in C++ class. Notice that only one default constructor is permitted, but in case of parameterized constructor, you can define more than one parameterized constructor because we can pass arguments in parameterized constructor. Now notice one more thing. If I comment this default constructor and if I only define parameterized constructor, then it is also possible. But in this case, this statement will show an error message. You can see it here. It is showing errors here because default constructor is not defined for these two objects. So if I make comment these statements, then our program will be executing successfully. You can see now it is printing correct results because I have not defined default constructor and I have not created any object for default constructor. So if you want to define only parameterized constructor, then you have to create the objects for parameterized constructor only. You can't create objects which are calling default constructor. And vice versa is also possible. If you are creating only default constructor, then you can't create objects which are calling parameterized constructor. So I hope you have understood the difference between default and parameterized constructor very well. I have focused upon all the issues which are applicable in both the cases. If you want to watch more programming related videos, you can search my channel on YouTube by typing my name Sanjay Gupta. Here various programming related videos and playlists are available. You can improve your programming skills by watching these videos. Don't forget to subscribe my YouTube channel. Thank you for watching this video.