5. Copy Assignment Operator Overloading C++

  Рет қаралды 6,619

CSExplained

CSExplained

Күн бұрын

Пікірлер: 47
@charlesfleetwood3914
@charlesfleetwood3914 3 жыл бұрын
Your videos are the best I have come across on C++ you take the time to thoroughly explain what is going on and why.
@csexplained4639
@csexplained4639 3 жыл бұрын
Glad you found them useful. Please share!
@zacharygammo7269
@zacharygammo7269 Жыл бұрын
Amazing video, this finally just made it simpler than I ever though ti was
@csexplained4639
@csexplained4639 Жыл бұрын
Glad you liked it! Please share.
@Naruto-hb9cg
@Naruto-hb9cg 2 жыл бұрын
your explanation is the best , is very clear tnx sir
@csexplained4639
@csexplained4639 Жыл бұрын
Glad it was helpful
@mocha3310
@mocha3310 2 жыл бұрын
thank you for the help. idk why but this video clicked so well with me.
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it helped.
@michaelatorn8380
@michaelatorn8380 2 жыл бұрын
Amazing tutorial! Most reference pages and tutorials lack the graphics for understanding the underlying memory concepts. Thank you.
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it was helpful!
@srikanth595
@srikanth595 2 жыл бұрын
Nice video, going up from basic to the intricate parts of the feature.
@csexplained4639
@csexplained4639 2 жыл бұрын
Thanks! 👍
@The_Programming-Teacher
@The_Programming-Teacher 3 жыл бұрын
your explain is very simple , thank you
@csexplained4639
@csexplained4639 3 жыл бұрын
Glad it was helpful!
@slowcoding
@slowcoding 2 жыл бұрын
Super useful to understand the concept. The diagram is really helpful to grab how the memory is managed. Thank a lot.
@csexplained4639
@csexplained4639 2 жыл бұрын
You are welcome
@dodosoni7705
@dodosoni7705 2 жыл бұрын
Really liked your tutorial as u explained everything briefly that most of the youtube channels lack in👍🏻
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it was helpful!
@csexplained4639
@csexplained4639 3 жыл бұрын
If you have any questions, please put them here. I'd be happy to answer them.
@dolevabuhazira1334
@dolevabuhazira1334 3 жыл бұрын
You are great.
@csexplained4639
@csexplained4639 3 жыл бұрын
@@dolevabuhazira1334 Many thanks!
@nmuralimohan4377
@nmuralimohan4377 3 жыл бұрын
Very clear explanation!
@csexplained4639
@csexplained4639 3 жыл бұрын
Thanks!
@BlockchainBob
@BlockchainBob 2 жыл бұрын
great visuals and explanation!
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad you liked it!
@zx5939
@zx5939 2 жыл бұрын
Great explanations! Thank you
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it was helpful!
@creationpower333
@creationpower333 Жыл бұрын
Thank you for helping us!
@420thlegioner8
@420thlegioner8 2 жыл бұрын
Such a detailed explanation, really good job.
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it was helpful!
@dodosoni7705
@dodosoni7705 2 жыл бұрын
Superb explanation!!! Hats off to u sir 🎩
@csexplained4639
@csexplained4639 2 жыл бұрын
Thanks a ton
@yogendragangwar9795
@yogendragangwar9795 3 жыл бұрын
A very nice explanation .. :)
@csexplained4639
@csexplained4639 3 жыл бұрын
Thanks! Glad you liked it.
@Mohamed_bhr66
@Mohamed_bhr66 2 жыл бұрын
very helpful, thanks for the effort.
@csexplained4639
@csexplained4639 2 жыл бұрын
Glad it was helpful!
@blaisofotso3439
@blaisofotso3439 3 жыл бұрын
Hallo , why do you have to return the dereference this pointer(*this) and how do you get the value in main after you return it? Will be happy if you can provide me with a pictorial explaination as in minute 3:00 in your video
@csexplained4639
@csexplained4639 3 жыл бұрын
"We return *this to support operations like a = b = c. b=c evaluates to "b" because of this return statement. If we are just doing something like a = b, the return value is simply not going to be captured. Hope this helps!
@srikanth595
@srikanth595 2 жыл бұрын
Though this (using references) seems to be a standard way of returning a value efficient ly, how does c++ handles the reference when it is assigned to an object because we are assigning a reference to an object - not to a reference object.
@csexplained4639
@csexplained4639 2 жыл бұрын
Sorry, not sure I understand what you mean. Can you please rephrase?
@srikanth595
@srikanth595 2 жыл бұрын
We are assigning a reference to an object, how does c++ handle this? Normally we assign an object to another object or a reference to another reference,,
@youssefgbb
@youssefgbb 3 жыл бұрын
Thanks a lot, I have a question, why do we use return by reference in the operator =, I know if we are returning with value (a = b) = c does not work (not compiler error,) value of b will assignment in a but value of c does not assignment to a,why does it not work,Can you explain to me in depth what exactly is going on.
@csexplained4639
@csexplained4639 3 жыл бұрын
Sure. Since we have parenthesis, whatever is between parentheses will be evaluated first. If you are not returning by reference, then the statement (a=b) will create a copy of b as a return value for (a=b). Let's call the returned copy "temp". Now, the result b is copied into c and the returned value temp = c. Therefore, c is going to be copied into temp, not b. This is not behavior that you want, I believe.
@youssefgbb
@youssefgbb 3 жыл бұрын
@@csexplained4639 thnak you soooooo much sir i understod
@Impromptu21
@Impromptu21 3 жыл бұрын
thanq bhava
@heartsonny
@heartsonny 2 жыл бұрын
Hello sir, I have two questions. Do we have to use "this" inside the operator= function? Can't we omit it and say, size=rhs.size instead? Also in my textbook, the Vector& operator= function is written as : const Vector& operator= . What is the use of const there and why? Thanks for the video by the way. Great explanation :) Best wishes
@csexplained4639
@csexplained4639 2 жыл бұрын
Hi Duygu, Omitting the "this" is fine. However, using "this" improves the readability by making it explicit that you are referring to the member variable "size". Returning a const reference is not is not typical. en.cppreference.com/w/cpp/language/copy_assignment Glad the explanation helped. What college do you attend?
5. Copy Constructors C++
10:21
CSExplained
Рет қаралды 6 М.
Copying and Copy Constructors in C++
20:52
The Cherno
Рет қаралды 442 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН
So Cute 🥰 who is better?
00:15
dednahype
Рет қаралды 19 МЛН
Леон киллер и Оля Полякова 😹
00:42
Канал Смеха
Рет қаралды 4,7 МЛН
C++ Overloading the Assignment Operator  [4]
17:38
Professor Hank Stalica
Рет қаралды 8 М.
C++  Tutorial: Rule of 5  [move constructor, move assignment operator]
29:46
Professor Hank Stalica
Рет қаралды 20 М.
Define A Copy Constructor To Create A Deep Copy Of An Object | C++ Tutorial
17:06
References in C++ Explained
14:21
Caleb Curry
Рет қаралды 105 М.
std::move and the Move Assignment Operator in C++
16:06
The Cherno
Рет қаралды 180 М.
Don’t Choose The Wrong Box 😱
00:41
Topper Guild
Рет қаралды 62 МЛН