Constructor in C++ | Calling types | OOPs in C++ | Lec-18 | Bhanu Priya

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi students in the previous video I explained about the constructor and the different types of constructor so the different types of constructed I explained about the default constructor parameterised constructor and the copy constructor okay so these are the three different types of constructor now let us see the different ways of calling a constructor okay the ways of calling the constructor so if you want to call a constructor you can use this different ways so the first one is the implicit call implicit call and second is the explicit call a explicit call and the third one is the dynamic initialization dynamic initialisation so these are the three different ways of calling implicit con explicit call dynamic initialization so let us see what is this implicit call so implicit call means calling the constructor by its object it simply means calling the object so recalling the constructor by its object we do not specify constructor name here okay so just it's calling the constructor by its object here we do not specify any constructor name so example for this implicit call means just Circle C is the object 3.5 so here just I'm enter the value here implicit call calling the constructor by its object now let us see the explicit call so what is this explicit call so constructor is called by its parameters if the constructor is called by its parameter then you call it as a explicit call so what is it the example for explicit call so here the circle is the class name sees the object is equal to circle three point five here the constructor is called by its parameters so here the constructor is called by its parameter then you call it as explicit call here is just implicitly your writing and this is explicit now coming to the dynamic initialization so dynamic initialization means first first memory is allocated so first the memory is allocated to the object using default constructor so in the dynamic in is initialization first memory is allocated to the object by using default constructor then parameterised constructor is called so after the egg allocating the memory then parameterised constructor is called to initialize to initialize datum members okay that you call it as a dynamic initialization means the first memory is allocated to objects first memory is allocated to object using default constructor so by using any default values or you can just allocate the memory to the objects after that the parallel parameter is constructor is called to initialize the data members so first it declares takes the default values after that the user is giving the values to that particular data members to that variables that you call it as a dynamic initialization the syntax for this is sorry Circle C okay so I can say is a name and the object so now the first memory is allocated to this object see after that float X so here is I declare the value now I'm just reading this value C in X so after that C is equal to circle of X okay so this x value will be entered by the user okay at the time of running the program that is it that you call it as a peril a parameter is constructors so this is the parametrized constructor the circle X so these are the three different ways of her calling the constructor you can call the constructor by implicit call or explicit call or dynamic initialization now let us see the the characteristics the special characteristics of the special characteristics of constructor so what are the characteristics of the constructors let us see so you have to follow some rules like that this the first one is they they should be declared in public section so if you want to declare the construction you have to be note that that there should be declared in only public section next they do not have any return type so did you observe it program so whatever the constructor wherever the we use the constructor the constructor name is same as a class name so there we we are not using any return time not even void also not even so not even void okay so first there should be declared in public section after that they do not have any written type values not even void next they get automatically in work when object is created so already I had say that I said that this constructors will be automatically in work then object or created now so they cannot be inherited through derived class so you have to be note that they cannot be inherited through derived class and can call the base class constructor means they cannot be inherited the derived class can call the base class constructor and next one like other functions actually the constructor is itself as a function so like other functions they can have default arguments so you can enter the default arguments you can the sister the compiler will take the default arguments like other functions so next the concept of cannot be virtual constructors cannot be virtual so they allocate some memory space so if you declare the constructor automatically it occupies some space in the memory so they cannot be virtual like classes so class is a virtual whereas construct is not verse one but here one thing is class name is same as a constructor name but both are different just using the class name as a constructor name here the Constructors or not watch one whereas class can be a virtual so these are the different special characters that are therefore the Constructors thank you
Info
Channel: Education 4u
Views: 28,807
Rating: undefined out of 5
Keywords: implicit call to constructor in c++, implicit call in c++, c++ constructor tutorial
Id: dO2SVzJLFt4
Channel Id: undefined
Length: 9min 40sec (580 seconds)
Published: Wed Jan 03 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.