Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL
I rarely comment on TH-cam..But this is a very clear nd solid explanation that i found difficult to understand elsewhere out in the internet..Thank you SIR :)
Why don't we directly write old instead of &old shouldn't it make old a copy of the class passed for eg if we write sample s2(s1) then old is a copy of s1 and thus a=old.a because this is how we pass integers also for eg: print(int num) { cout
I would like to bring your attention towards syntax of copy constructor and importance of const keyword. const keyword should be added to avoid accidental modification ,a temporary object cannot bind to a non-const reference
In c++ there is default copy constructor. No need to write separate copy constructor until unless use the dynamic memory allocated to avoid dangling pointer. Sir my sincere request pls give the proper subject to the learners.
sir i have a doubt regarding the calling of the copy constructor.... in void main... shall it be sample &s2(s1) ???? please reply sir..!! best xplanation ..!!thanks alot sir..!!
(*this).a and this->a are different syntax for the same operation. You are right that -> is a typical java operator, but it is implemented in newer C++ as well.
I would like to bring your attention towards syntax of copy constructor and importance of const keyword. const keyword should be added to avoid accidental modification ,a temporary object cannot bind to a non-const reference
The reference variable means "An alternative Name for the previously defined variable or object or whatever" So when Sample S2(S1) is passed; that means the object S1 is got new name of "OLD" Now, as you can see S1 object has for a= 10 and b = 20; So, in S2, a = old.a; //old is object S1 b = old.b //old is another name for object S2
Let's say you need to create the same object twice (or more) and you need to change one of them during your program or whatever... This is how you should create the same objects
I think you have to use constant for reference object in copy constructor parameter, otherwise the old object values can be manipulated inside copy constructor, just a suggestion from my side.
Good, thanks for the lesson. But everyone's using copy contructor even when they assign as s1=s2. Why's copy constructor also invoking at such occurrence? Anyone knows? :)
Brother both are valid statement just we need to understand that this s2 value is passing In the constructor.like if we pass two values in constructor we write like s1(4, 3) if we need to pass only one parameter then s1=4 this way is also correct
Please Comment, Subscribe and Click Bell🔔🔔🔔 Icon for More Updates. To learn software course from our experts please register here for online training: goo.gl/HIB0wL
conio.h is only in Turbo C++, what is the similar header file for standard C++ ?
this is only shallow copy constructor, you forgot deep copy constructor.
If i dont want to write copy constructor then what is another option for copy constructor...
Plz guide...
I got tired to search & see the many lectures on Copy Constructor but didn't understand, BUT THIS 15 MIN VIDEO TAUGHT ME FROM SCRATCH. THANK U SIR
I rarely comment on TH-cam..But this is a very clear nd solid explanation that i found difficult to understand elsewhere out in the internet..Thank you SIR :)
Ur teaching technique is impeccable sir.Respect 🙏
Sir you have excellent explanation better than my teacher you explain everything clearly.
Thnx for helping me study in quarantine...🙏🏻
excellent explanation sir...my all concepts of constructors are get cleared by watching this video......
Oh thank you! this is the first time i actually understood copy constructor!
Thank you Naresh technologies for making concepts so simple.
Very good explaining, excellent ! Thank so much from Ukraine
One of the best lecture on Copy Constructor......😊
Super and nice prof. i have ever seen in USA!!!!
I appreciate Mr. Kishore for such videos. Nice work . Keep going
Excellent explaination sir... Thanks a lot.. upload all videos related to c++
Has to be the most vivid explanation on copy constructors.
Excellent.. you make people's life easier.👍
Best explanation in the world.
Thank you sir you help in understanding the topic easily 🙏
Thank you Sir for this video, Sir please make a video on Parameterized Constructor
tiz is first time understood da copy constructor after watching ur videos sir tqqq
excellent explanation sir.... thank you so much
Best explanation , thank you sir.
this is the best explanation by far!
Awesome xplanation sir
Tq very much
Very well explained keeping the grips on the essential part of the programs.
It's so useful for me
Thank you so much
Perfect n smooth explanation
Explanation super ga undi mi videos download chasukunna from play store
superb sir Thank You 🙏
Very good lecture
Sir please make a video on Parameterized Constructor
It is there in playlist
Why don't we directly write old instead of &old shouldn't it make old a copy of the class passed
for eg if we write sample s2(s1) then old is a copy of s1 and thus a=old.a
because this is how we pass integers also
for eg:
print(int num)
{
cout
amazing teacher ı like your way of explaining the ideas
Good explanation about copy constructor.
Excellent👍
Very good explanation. Thank you.
thank u it is very useful for me to understand inheritance
Very good explanation sir
Thanks a lot sir, really great explanation
Great Explanation , Thankyou
Sir ... I don't know why u have deleted the symbal & at timestamp 11:25 ..? anyone plz clarify
Great 🙏
Perfectly awsome🥰
Super Explanation Sir
I would like to bring your attention towards syntax of copy constructor and importance of const keyword. const keyword should be added to avoid accidental modification ,a temporary object cannot bind to a non-const reference
thank you so much sir wonderful explanation
thank you sir, u r real kind teacher
The reference object passed should be const in nature (preferebly)
Thank You sir !
If you gave example with pointer and shallow copy and deep copy in this topic it will much helpful to all
Thank u sir hats of u
If you are coping all the value of s2 in copy constructor then why do you used parameterize constructor ...
Ans please🙏🙏🙏
I have a question: a and b are private variables of s1, using reference variable can bypass data hiding then?
supper se upper sir
Thanx for helping
Best♥
Sir U haven't made any video on parameterized constrictor please make one video on it
Brilliant
U r great sir
good one..
His English accent is just perfect than any other Indian peoples :3
Who is having exam tomorrow?
Phati padi hai bhai
Yes bro. Watching at 1.75× to save time..😂😂
In c++ there is default copy constructor. No need to write separate copy constructor until unless use the dynamic memory allocated to avoid dangling pointer. Sir my sincere request pls give the proper subject to the learners.
sir i have a doubt regarding the calling of the copy constructor.... in void main... shall it be sample &s2(s1) ???? please reply sir..!!
best xplanation ..!!thanks alot sir..!!
givl pgg
Excellent
Sir will you please clarify ,why you used & in copy constructor
copy constructors depends on reference(&) to same class type.
thank you sir...
There should be use of const operator in copy constructor argument. Pls check
awesome sir
Sir but "this" function me . Nhi chalta na wo to java me hota hai.....cpp me this-> aisa hota hai na shyad???
(*this).a and this->a are different syntax for the same operation. You are right that -> is a typical java operator, but it is implemented in newer C++ as well.
Sometimes we make use of "const" keyword in copy constructor(like sample (sample const &old) What's the purpose?
I would like to bring your attention towards syntax of copy constructor and importance of const keyword. const keyword should be added to avoid accidental modification ,a temporary object cannot bind to a non-const reference
What is the relavance of &old there
Can you please explain
The reference variable means "An alternative Name for the previously defined variable or object or whatever"
So when Sample S2(S1) is passed; that means the object S1 is got new name of "OLD"
Now, as you can see S1 object has for a= 10 and b = 20;
So, in S2,
a = old.a; //old is object S1
b = old.b //old is another name for object S2
where is the parameterized constructor video?? Can anyone share the link??
I believe the answer will be 10,20 and 10,20
If the answer is same twice, what is the use? ,🤔🤔🤔
Let's say you need to create the same object twice (or more) and you need to change one of them during your program or whatever... This is how you should create the same objects
What is shallow and deep copy ???
Sir can we write s2=s1 like this?
best sir
sir in dev c++ software . its showing error when I place . when I remove (.h) its compiling . can u please give me reason sir
When we use turbo c++ or any old complier (I think ) then we need to use .h otherwise in visual studio or other new compilers there is no need
thanks sir
can u pls explain C programming
Add more session sir
What about copying pointer variables?
I think you have to use constant for reference object in copy constructor parameter, otherwise the old object values can be manipulated inside copy constructor, just a suggestion from my side.
Sir where is parameterized constructor??
Watch video number 31 , overloading example 1
Good, thanks for the lesson. But everyone's using copy contructor even when they assign as s1=s2. Why's copy constructor also invoking at such occurrence? Anyone knows? :)
Brother both are valid statement just we need to understand that this s2 value is passing In the constructor.like if we pass two values in constructor we write like s1(4, 3) if we need to pass only one parameter then s1=4 this way is also correct
sir,why you removed & in s2
That should not be there
Sample (S2)=S1 Equals to sample S2 = S1, so & is not required
I think the syntax is class_name(const &old_obj);
where is parameterized constructor video??
lect 30 then 35 then 34
Asp mere ko thik se Nahi samjha maye
Thank you very much sir. . very well explained !
thank you soo much sir
thank u sir
Great sir
explanation are up to the point and can easily understand sir.tnq sir