Two weeks ago I was watching another channel for learning C++, the other channel was good, but THIS CHANNEL IS WAYS BETTER. Very well explained, thank you so much.
No, right now I just have videos in the C++ Tutorial playlist covering lots of different OOP concepts. One day I would like to make a whole video covering OOP in C++ that is more of a "full course".
@2:17 num2=num1; is using copy assignment operator function, instead copy construct. num2(num1) is using copy construct in my knowledge. That’s very confusing. But concept must be right.
I did not receive any errors when the exit() was removed. Should I be worried if I dont receive errors or is it just depending on the software? I use vscode.
I get why you’re using malloc and free in this case (ie to throw the error) but really you should mention this is not considered good practice (and mention new/delete/smart pointers)
Yes Ibrahim. :-) I used malloc() in this video thinking that many programmers would be coming from C and may be more familiar with it, but a "C++ way" of doing it would be to use new instead.
Great question Akash! :-) Because we will not modify otherNumber, we just use it to make the copy. It would be a mistake if we did. So we help enforce this with the language feature const.
You're welcome Abdellah! :-) The code in this video is found here, does using this exact code help resolve the issue? github.com/portfoliocourses/cplusplus-example-code/blob/main/copy_constructor.cpp
One day I'm going to make a video on dynamic memory allocation in C++. :-) The big difference is whether the constructor/destructor is called or not though, this might be helpful in the meantime: www.geeksforgeeks.org/new-vs-malloc-and-free-vs-delete-in-c/
@@PortfolioCourses i know what dynamic memory allocation is. What you mean is that when you use New keyword you have to use the delete in order to free the allocated memory, while in alloc it’s done automatically?
@@Vichained No, with malloc and calloc you need to free the memory that's been allocated, it's not automatic. With new and delete, the constructor and destructor of any object will be executed, with malloc/calloc/free, the destructor and constructor will not be executed.
Two weeks ago I was watching another channel for learning C++, the other channel was good, but THIS CHANNEL IS WAYS BETTER. Very well explained, thank you so much.
Thank you for being so supportive Eduardo, I'm glad you've found the C++ videos on this channel to be helpful. :-)
Oh Man, you're so great at teaching! No nonsense at all, just directly goes into the knowledge we need!
everytime i dont fully understand some new concept, i come to this channel and everything starts to make sense!
That's awesome Matheus, that makes me very happy to hear that the channel is helpful for you, thanks so much for sharing this! :-)
I subed
The pace and tone of these tutorials are pretty good, the information penetrates my brain when I watch them
That’s awesome to hear, and welcome aboard! :-)
Thanks a ton! Your students are lucky to have an amazing professor like you!
You're welcome Valli-Nayagam, and thank you for the kind words! :-)
every time i want to revise this topic i end up here thank you so much
Deep copy and Shallow copy concept sorted! Thank you!
Very thorough explanation with great examples. Thanks for clarifying!
You're welcome, I'm glad it was helpful! :-D
don't be bored telling the same thing: you're the best instructor
This was extremely helpful and clear thank you so much.
You're welcome! :-)
I love u holy moly i was realy scratching my head on copy constructors
I'm glad to hear this video helped you out Austin! :-)
Thanks a lot, this helped me solve a programming exercise i was stuck at.
You’re very welcome! :-)
Excellent explanation!!
I'm glad you enjoyed it! :-)
@@PortfolioCourses do you have whole video like this on oops?
No, right now I just have videos in the C++ Tutorial playlist covering lots of different OOP concepts. One day I would like to make a whole video covering OOP in C++ that is more of a "full course".
@2:17 num2=num1; is using copy assignment operator function, instead copy construct. num2(num1) is using copy construct in my knowledge. That’s very confusing. But concept must be right.
Excellent video!
I’m glad you enjoyed it, and thank you very much! :-)
great explanation, thank you
You’re welcome! :-)
This is so helpful, thank you so much
You're welcome! 🙂 Thank you for letting me know it was helpful for you.
I did not receive any errors when the exit() was removed. Should I be worried if I dont receive errors or is it just depending on the software? I use vscode.
thanks very much brother man🙌
You're welcome Isaac! 😀
Really helpful
Thanks
You're welcome Kevin! 🙂
I get why you’re using malloc and free in this case (ie to throw the error) but really you should mention this is not considered good practice (and mention new/delete/smart pointers)
thx alot!
instead of malloc statement can we use new keyword?
Yes Ibrahim. :-) I used malloc() in this video thinking that many programmers would be coming from C and may be more familiar with it, but a "C++ way" of doing it would be to use new instead.
why is const have been used in "Number(const Number &otherNumber)"
Great question Akash! :-) Because we will not modify otherNumber, we just use it to make the copy. It would be a mistake if we did. So we help enforce this with the language feature const.
hello, first i would to thank you for this tutorial, i do exactly the same thing in my computer but the deep copy he dosen't work, can you help me?
You're welcome Abdellah! :-) The code in this video is found here, does using this exact code help resolve the issue? github.com/portfoliocourses/cplusplus-example-code/blob/main/copy_constructor.cpp
@@PortfolioCourses thank you so much for your videos, it's very helpful, i searched on internet and it's working now, thank you.
@@abdellahguennioui1568 Awesome I'm glad to hear you got it working, and you're welcome Abdellah! 🙂
whts the diff between new and malloc?
One day I'm going to make a video on dynamic memory allocation in C++. :-) The big difference is whether the constructor/destructor is called or not though, this might be helpful in the meantime: www.geeksforgeeks.org/new-vs-malloc-and-free-vs-delete-in-c/
@@PortfolioCourses i know what dynamic memory allocation is. What you mean is that when you use New keyword you have to use the delete in order to free the allocated memory, while in alloc it’s done automatically?
@@Vichained No, with malloc and calloc you need to free the memory that's been allocated, it's not automatic. With new and delete, the constructor and destructor of any object will be executed, with malloc/calloc/free, the destructor and constructor will not be executed.
@@PortfolioCourses ohhhh gotcha. Thanks kevin
@@Vichained You're welcome! :-D