Difference between copy constructor and assignment operator in C++ (OOP tutorial for beginners)

  Рет қаралды 8,604

CodeBeauty

CodeBeauty

Күн бұрын

Пікірлер: 65
@CodeBeauty
@CodeBeauty 4 ай бұрын
🚀📈💻🔥 My Practical Programming Course: www.codebeautyacademy.com/ Experience the power of practical learning, gain career-ready skills, and start building real applications! This is a step-by-step course designed to take you from beginner to expert in no time!💰Use this coupon to save 10% (CODEBEAUTY_YT10). Use it quickly, because it will be available for a limited time. 📚 Learn programming with these Free E-Books ⬇ C++ Lambdas e-book - free download here: bit.ly/freeCppE-Book Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObjectPascalEbook *****CODE FROM THE VIDEO***** #include using namespace std; class Movie { public: string Name; string Genre; float Rating; Movie(string name, string genre, float rating) { Name = name; Genre = genre; Rating = rating; } Movie() { Name = ""; Genre = ""; Rating = 0; } Movie(const Movie& original) { Name = original.Name; Genre = original.Genre; Rating = original.Rating; } Movie& operator=(const Movie& original) { Name = original.Name; Genre = original.Genre; Rating = original.Rating; return *this; } }; int main() { Movie movie1("The Dark Knight", "Action", 9.5); Movie movie2("The Lion King", "Animated", 8); Movie movie3; Movie movie4(movie1); movie4 = movie2; //movie4.operator=(movie2); Movie movie5 = movie1; movie5 = movie2; cin.get(); }
@christopherrice891
@christopherrice891 4 ай бұрын
I've been waiting patiently for more coding videos in C++ and it looks like my patience is paying off because lookie here! A new C++ coding video🤗!! Thank You very much Saldina✌️!!
@CodeBeauty
@CodeBeauty 4 ай бұрын
Hahaha, I'm happy to hear that. Welcome back to another C++ lesson 🥰❤️
@KashafZia-d7p
@KashafZia-d7p 2 ай бұрын
These technical differences particularly how the memory is allocated and deallocated at the backend you taught through excel they are highly commendable. Dynamic allocation is the tough part for beginners but you explained really well the topic that is hard to find on youtube
@snehadey883
@snehadey883 4 ай бұрын
I am very excited for this video🥰I like your C++ programming tutorials, it helps me very much💝
@CodeBeauty
@CodeBeauty 4 ай бұрын
Happy to hear that! The video is out, hope you'll enjoy it 🥰
@yawsokpor3061
@yawsokpor3061 4 ай бұрын
Hi Iike your teaching method, the way you explained the difference between copy constructor and assingment costructor is very interesting
@MJavadZallaghi
@MJavadZallaghi 4 ай бұрын
Very good tutorial! Thank you.
@amirhosseinmoghimzadeh5887
@amirhosseinmoghimzadeh5887 4 ай бұрын
it was very good please publish more videos on OOP
@ahmedkarrar25
@ahmedkarrar25 Ай бұрын
OMG!! You're AMAZING thank u! ❤
@dabbabimarwen7474
@dabbabimarwen7474 4 ай бұрын
I Like The Way You Insist On Details I'd Like To See The Process Of Writing an object with A String Field In a Binary File : Save Method Good Continuation... ♥
@joebosah2727
@joebosah2727 4 ай бұрын
Thanks, SN Shallow Copy and Deep Copy Rule of 3 (and the lesser known Law of the Big Two)
@ProgrammerSolver
@ProgrammerSolver 4 ай бұрын
Great teacher, thank you so much, you have an easy explanation way i understand all what you say, much love for you Saldina, i hope i have enough money to pay for your course
@CodeBeauty
@CodeBeauty 4 ай бұрын
You are so welcome, and I hope that you'll join us in the course. You'll learn how to build real apps and get experience so that you can start a successful career as a developer 😊🥰
@ProgrammerSolver
@ProgrammerSolver 4 ай бұрын
I hope that too, but one day I will join I'm sure @@CodeBeauty ❤❤
@generalsub7
@generalsub7 18 күн бұрын
Thank you so much!!
@marquelamar
@marquelamar 4 ай бұрын
Nice lesson! You look great today.
@CodeBeauty
@CodeBeauty 4 ай бұрын
Thanks 😃
@vkatasonov
@vkatasonov Ай бұрын
Hi, Sabina, you should probably add "Orthodox Canonical Style" to the video title:) trust me, a lot of people will look for it as soon as it explained quite poor in KZbin
@marcusantenor793
@marcusantenor793 27 күн бұрын
Hi can you make a video in that serie that talks about move constructor?
@nicholaskomsa1777
@nicholaskomsa1777 4 ай бұрын
It would make sense to also cover move constructor, move assignment operator, to be complete.
@CodeBeauty
@CodeBeauty 4 ай бұрын
I have a few more videos about constructors, destructor, copy c-tor on my channel. They should be in C++ OOP playlist, I hope they help to explain more stuff 😄😄👋
@jimpapay2895
@jimpapay2895 4 ай бұрын
Cool! Thank-you.
@CodeBeauty
@CodeBeauty 4 ай бұрын
You're welcome!
@AparnaSinghPanwar
@AparnaSinghPanwar 7 күн бұрын
copy constructor as movie class name is written before obj this means its a completely new obj being allocated memory
@fikirgunlugum
@fikirgunlugum 4 ай бұрын
We are waiting, and happy that the content picture does not include sub-messages. 😂
@CodeBeauty
@CodeBeauty 4 ай бұрын
The video is out. I hope you'll enjoy it 🥰
@naderhumood1199
@naderhumood1199 4 ай бұрын
Thank you Saldina....vedio is graat and Your gorgeous.
@CodeBeauty
@CodeBeauty 4 ай бұрын
My pleasure 😊
@muhmedgamal5841
@muhmedgamal5841 2 ай бұрын
Gooooood😊
@marcusantenor793
@marcusantenor793 27 күн бұрын
26:53 you imagine that the array contains 2 variables so that the explanation could fit better. However, so far in the lecture/code, the counter is set to 0 and the array is empty.
@سراجمصطفىمحمد
@سراجمصطفىمحمد 29 күн бұрын
I have a question when you delete the array of Pointers in the assignment operator and make a new srting dinamic array why the adress changes in Exel explanition althout u don't make Actors= nullptr?
@muatzdaw8283
@muatzdaw8283 4 ай бұрын
I great video to a greater teacher 🤍
@CodeBeauty
@CodeBeauty 4 ай бұрын
Thank you! 😃
@whitewolf4689
@whitewolf4689 3 ай бұрын
This is some high level content with low level programming! yess I know C++ is a high level programming language ok
@jhon3991
@jhon3991 3 ай бұрын
@CodeBeauty The assigment operator returns a reference to the Movie other then an address of Movie. How do you think about that? See 13:25, for detail. If I am wrong, please let me know.
@Zulu-xe9zm
@Zulu-xe9zm 4 ай бұрын
We are waiting
@CodeBeauty
@CodeBeauty 4 ай бұрын
The video is out now 😊🥰
@jorgetorres1670
@jorgetorres1670 4 ай бұрын
Thanks.
@CodeBeauty
@CodeBeauty 4 ай бұрын
You're welcome
@Muhammadaliofficial5
@Muhammadaliofficial5 4 ай бұрын
What is difference between constructors and structures
@CodeBeauty
@CodeBeauty 4 ай бұрын
They are related concepts, but they don't represent the sam thing. Watch my video about structures, and you'll learn what structures are with examples 😊
@samialvi4226
@samialvi4226 4 ай бұрын
Are we going to build gui apps as well plsss!
@danielkoziarski8488
@danielkoziarski8488 4 ай бұрын
I do not understand why initializer list has been omitted for the demonstrated constructors. 😢
@CodeBeauty
@CodeBeauty 4 ай бұрын
I can not put everything in one video. It's already very long 😅😅
@mauzaomin3872
@mauzaomin3872 4 ай бұрын
Why not deleting the newActor to free up the memory?
@CodeBeauty
@CodeBeauty 4 ай бұрын
newActor is just holding the address in memory, and in that memory, we have data that we need, so if we free that memory, we'll lose the data that we need
@chrishabgood8900
@chrishabgood8900 4 ай бұрын
do you use either of these in your day job?
@CodeBeauty
@CodeBeauty 4 ай бұрын
You'll probably not create copy c-tors and assignment operators every day, but you'll definitely use them daily in your work, so if you for example get a bug and you don't understand this in depth, you'll have no idea how to fix the bug and make your code work
@jackschitt7783
@jackschitt7783 4 ай бұрын
I'm here for clickbait. Nice hat! They say comments help the "algorithym". Done. Redundantly. :)
@CodeBeauty
@CodeBeauty 4 ай бұрын
Hahah, they do, thanks for the comment 😄 🥰
@nevram0101
@nevram0101 4 ай бұрын
👍
@CodeBeauty
@CodeBeauty 4 ай бұрын
👋
@skykid1075
@skykid1075 4 ай бұрын
She is my lovely cat sweet girl ! only mine !!!!!!!! Please do more videos !!!!!!!! 😘😘😘😘😘😘😘😘😘😘😘😘😘 I LOVE YOU KISS KISS KISS KISS KISS LOOOOOOOOOOVE .
@CodeBeauty
@CodeBeauty 4 ай бұрын
🥰🥰
@skykid1075
@skykid1075 4 ай бұрын
@@CodeBeauty 😘😘😘😘😘
@SDRicky
@SDRicky 3 ай бұрын
Ur accent is damn cute 🥺
@CodeBeauty
@CodeBeauty 3 ай бұрын
It's the first time someone says that to me. Thank you so much 🥰🥰
@artstechnology7809
@artstechnology7809 4 ай бұрын
Dont speaks English not understand english. My favorite programming language of computers 😢😢😢
@CodeBeauty
@CodeBeauty 4 ай бұрын
Your English is not bad 😊😊
@artstechnology7809
@artstechnology7809 4 ай бұрын
@@CodeBeauty I really don't know English, I'm answering you with google translate. This science of programming attracts me so much that I want to practice it and learn it perfectly. But I don't know, this also prevents me from learning after you. 😥
@kitcat2449
@kitcat2449 3 ай бұрын
​@@artstechnology7809Try to see if chatGPT can help you as well. It can explain code blocks line by line and translates quite well to other languages!
@nicholaskomsa1777
@nicholaskomsa1777 4 ай бұрын
While an assignment-copy is a "Deep Copy", moving is a "Shallow Copy". Shallow copy steals pointers rather than duplicate their contents. here you go: struct Movie { std::string title; int year; Movie() { std::cout
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН
Как подписать? 😂 #shorts
00:10
Денис Кукояка
Рет қаралды 3,6 МЛН
АЗАРТНИК 4 |СЕЗОН 2 Серия
31:45
Inter Production
Рет қаралды 1 МЛН
Coding Was HARD Until I Learned These 5 Things...
8:34
Elsa Scola
Рет қаралды 405 М.
Copying and Copy Constructors in C++
20:52
The Cherno
Рет қаралды 428 М.
Move Semantics in C++
13:10
The Cherno
Рет қаралды 291 М.
SMART POINTERS in C++ (for beginners in 20 minutes)
24:32
CodeBeauty
Рет қаралды 99 М.
Premature Optimization
12:39
CodeAesthetic
Рет қаралды 805 М.
Friend functions and classes in C++ (Programming for beginners)
18:18
Angry Sigma Dog 🤣🤣 Aayush #momson #memes #funny #comedy
00:16
ASquare Crew
Рет қаралды 50 МЛН