C++ OOP (2020) - What are constructors and class methods? How to use them?
HTML-код
- Опубликовано: 28 сен 2024
- In this video, I'm explaining when, why, and how are constructors and class methods used.
📚 Learn how to solve problems and build projects with these Free E-Books ⬇️
C++ Lambdas e-book - free download here: bit.ly/freeCpp...
Entire Object-Pascal step-by-step guide - free download here: bit.ly/FreeObj...
🚀📈💻🔥 My Practical Programming Course: www.codebeauty...
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!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.
Download Visual Assist here: bit.ly/WT-CB
I use it to enhance the performance, features, and support for C, C#, and C++ development in Visual Studio.
Download Ultra Edit here: bit.ly/UE_CB
It is a powerful, secure text editor designed specifically for programmers.
☕ If you've found my content helpful and would like to support me, you now have the option to buy me a coffee or a cookie! It's a small gesture of gratitude that means a lot to me and helps me keep creating free educational videos for you. You can use the link below to make a contribution: bit.ly/CodeBea...
However, please don't feel obligated to do so. I appreciate every one of you, and I will continue to share valuable content with you regardless of whether you choose to support me in this way. Thank you for being part of the Code Beauty community! ❤️😇
Introduction to OOP - • C++ OOP - Introduction...
If you are a beginner in C++, check out my "C++ for beginners" course: • C++ FOR BEGINNERS (202...
"C++ functions" course:
• C++ FUNCTIONS (2020) -...
Follow me on other platforms:
Instagram 📸 - / truecodebeauty
Twitter 🐦- / truecodebeauty
******INITIAL CODE IS IN THE COMMENTS******
📚 Learn how to solve problems and build projects 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
🚀📈💻🔥 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!
💰 Here is a coupon to save 10% on your first payment (CODEBEAUTY_YT10).
Use it quickly, because it will be available for a limited time.
#include
#include
using namespace std;
class RUclipsChannel {
public:
string Name;
string OwnerName;
int SubscribersCount;
list PublishedVideoTitles;
};
int main()
{
RUclipsChannel ytChannel;
ytChannel.Name = "CodeBeauty";
ytChannel.OwnerName = "Saldina";
ytChannel.SubscribersCount = 1800;
ytChannel.PublishedVideoTitles = {"C++ for beginners Video 1", "HTML & CSS Video 1", "C++ OOP Video 1"};
cout
Welcome me 😍 friend.
@@Павелик-з4е Hahaha, welcome! 🤗
@@CodeBeauty 🇰🇿
Wow, I'm glad to see that people are watching me on the other side of the world! Қош келдіңіз! ☺️
@@CodeBeauty менің RUclips каналыма үлкен рахмет, мен сізді көргеніме қуаныштымын.🙂
Usually, I don't comment...but after three years of programming and finally understanding constructors I want to say THANK YOU🌸- and I mean it!! Your explanations are comprehensible and finally there's a way for me to understand what I'm supposed to do with all that code. Coffee bought☕
Thank you so much 🥰💞
I've read plenty of c++ ebooks and they are very comprehensible, but your way of explaining class and objects in this video is way more comprehensive. Starting with simple way of creating class and then how you can create multiple classes without having to repeat the same codes. This is better than how I learn it in college. AMAZING 👏
Can you suggest some good books
Three years already and your videos are still very useful. God bless you, Saldina
🙏💙
i used to dread C++ until i started following this channel. Teaching is a s skill. Thank you so much...
I understood 100%. Now I see the meaning of the constructors. *Thank you so much, Saldina.*
Great! I'm happy to help 🤗
Thanks Saldina. It would be great if you could also cover destructors, virtual destructors, delete, and related dynamic memory parts when you have time in future.😀
Feeling very lucky after found this channel 😇
Thank you so much for explaining this, my professor in college blew through this and it's immensely helpful to see your examples! Going to watch this whole series of videos
watched five different videos about classes and your video made it all click, thank you. you saved my life
Thank you so much for these gems. Helps me to become exponentially better in programming, maybe I'll top my branch this semester.
Wow, good luck, I'm so glad to hear that top level students are learning from my channel 😃😃
everyone who do such works,give time ,and bring such content is worthy to be appreciated,plz bring data structures too.
One of my favorite songs is Baker Street by Gerry Rafferty. A side note on terminology, I have heard the different arguments in an overloaded function called the function's signature.
I like that you adopt this "show me the problem with something" before you introduce the new concept that was meant to be the solution.
I really wanna thank you because i am really struggling with C++ and your instructions are so clear and your verbalism, the way you talk is also great and understandable. All these coding videos there's always some guy who is indian and speaking with a terrible accent so i can't really understand from them sometimes (english is my second language) you saved me really! subscribed
I have to admit that your video is absolutely clear. Thats why I choose to watch your video despite language difference
THANK U MAM 🙇♀️
LOVE FROM INDIA❤️
Thanks a lot! I love your explanation and the way you've used relatable class's name and objects ☺️
I dont usually comment on videos but this really helped. Im very new to programming and struggling alot and this video really helped me understand constructors. THANK YOU!
I appreciate your hardwork to make these videos at 3am.
I have had more success with your videos gaining practice and understanding foreign concepts.
🥰🥰🤗
My favorite song is Circe's Spell from Kalidia band. Kisses from Brazil, Saldina...
Muitos beijos para o Brasil 🥰❤️
Aaaaa taj naglasak mogu prepoznati u snu. Inace odlicni snimci i nadam se da ces nastaviti sa njima od mene samo reci hvale i podrske
So far, so good 🙂
...
Song: Where I am - Freetown Collective.
I am really new with programming. The way you teach by comparing old methods with new one is remarkable !
It make me understand about why it happened and why it matter
Thank you
I love ur videos!! It'll really help me with my finals🌸
Thank you very much your videos are very helpful! I stopped go to my classes in uni and instead I'm watching your videos and learning much more!
Great tutorial! So clear and well paced!!!
I love you so much really thankkk you!!!!!!!!!!!!!!!!! finally i found someone who teaches really REALLY WELLLL
Little late but my favorite song is Beast of Burden by The Rolling Stones. Thanks for your videos!
my TA recommended you THank you Belen and thank you it was really helpful
🙌🥰
best explanation I found so far, thanks!
Does she have a video showcaseing her Setup so I can have thoose shortcuts aswell in my compiler ?
Thank you! Much appreciated. This series are great!
Thank you for this video, I think you understand where I am having difficulties better than any other coding channel so I always look for your videos first now haha
Why do you not use initialiser lists in your constructors?
can we add the video title in the constructor as one of the elements that takes string?
excellently explained. thank you!!
Thank you so much. I had so much trouble understanding this in class
The song is called "Paradise by Lil Uzi Vert"....Please listen to it when you're driving and there's a sunset.
can you explain what the push_back() function does? Is that a predefined function? Very helpful vids btw.
Idk if this is any help now but push_back() appends whatever is in the parenthesis to the end of the string
@@zoejackson7184 push_back is one of the methods in the list class. remember you had a list of strings where you defined it as list sth.
now sth is a list of strings and when you want to add something to that list, you have several options, one of which is a method called push_back.
It would be nice to show how we can use a class from different translation units. How to write header file and cpp file in this case.
What can I say other than my jaws only dropped in amazement at how you easily delivered this.
you are really a great tutor
that is exactly what I was looking for, very helpful. thank you so much
Thank you so much. I finally understand constructors
Is there an advantage to using "list" instead of perse "PublishedVideoTitles string[100]" (so I guess an array)?
Also I really like rainbow in the dark by Dio
Clear explanation, pls do more videos in c++
miss saldina.. you made my day .. thank u so much
Can't we call a list inside a constructors? If yes why do you call PublishedVedioTitles as an attribute of the object?
My favorite bands, Mathew Sweet, NOFX, Face to Face, Tokyo Jihen, and Third Eye Blind
here's an arabic song you may want to listen to
Fayrouz - Sa'alouny El Nas / فيروز - سألونى الناس
Brilliant, Excellent, thanks so so muchh !!!!
Very clear && easy to understand, thank you!
Thank you my new mam for teaching c++ in very simple and easy way.
I am from India .so, Language becomes more barrier for me but in your case I didn't feel like this
due to your easy way of teaching and making the things related us by giving perfect example
once again Thank you so must...
you explained why very well. Thanks.
You are an excellent teacher, thank you very much!
Hi! Amazing tutorials,i watched only two ,for the moment, and i really like its.
understood, but, a light theme, really!
Magnificent 🎉
my favorite song is My Demise by RAINMNY also Decompression by RAINMNY is pretty decent too i love them so much haha xD
What if you want the user to input everything in the constructor instead of pre filling everything out?
It's litterally years later but I really like Taylor Swift- Sweet Nothing and You're on Your Own Kid. Also Hikari Are from Burnout Syndromes. By the way I LOVE YOUR VIDEOS YOU ARE GREAT AT THIS ehehehheh
Rammtein ❤ thank you so much for video
how to make a function which returns a value? for example a function in a class which returns the value of the area of a rectangle or any other calculations and etc? any recommended videos?
Thanks a lot! Your example choose very good.
Well :) my favorite song called I’m free it’s a soundtrack of a movie “spirit” and the singer is non other the legendary Brain Adams
so are methods, like void GetInfo, similar to functions?
you should deserve more subscribers ☺
i love carry you by ruelle
You should promote good practices from the begining, for example: initializing object’s fields after colon and not in the constructor’s body.
How you gonna casually drop a Scorpions song I've never heard before? Good tune
Love that song ❤️🥰
One of my favorite songs is Decks Dark by Radiohead rn
My favorite song is "Shamoon Ismail - rung"
Thanks for the videos from México!
Quick question: A class method is like a function inside a class?
Very good video 📸 deserve likes and subscription.
Please do python videos too.
what does this mean string videoTitle : PublishedVideoTitle ?? Please explain.
Such a great video. It was a great practice.
Well my favorite songs are "Sugar" by Maroon 5 and" We Don't Talk Anymore" by Charlie Puth
i am truly sorry for you
@@7barsofchocolate Why??
hi teacher my favorite song is Take me to your heart and Don't leave me alone.
A literal lifesaver
🥰🥰
Sweet home alabama is my fav song
I have a midterm tomorrow and let's see if you can save me. :D
Good luck 🤞
Thanks!
Thank you! 🥰🥰
Can we create array of an object, for defining /creating more objects?
I appreciate the way of teaching and great hardwork to prepare such a perfect videos. Excellent work by CodeBeauty!
to be honest you put my teachers to shame
I can’t agree with you more. I question what I’m paying for.
my favorite songs are eatfrommydinner - white stripe and frou frou - guitar song ! yay!
In the class RUclipsChannel, I added brackets to the end of "int SubscribersCount{};". I was getting an error -
Warning C26495 Variable 'RUclipsChannel::SubscribersCount' is uninitialized. Always initialize a member variable (type.6). It fixed the error and I am debugging in x64 if that might make a difference?
Another great video series. Thanks Everett
Thank you for your great job
🥰🤗
Is it ok if RUclipsChannel::PublishedVideoTitles was vector instead of list?
Hi 🤗
Vectors and lists internally are very different data collections. List stores elements at the non-contiguous memory locations and the vector uses contiguous memory.
This code here is very simple, so you can use both, but there are a couple of things to consider when it comes to using lists vs vectors if you want to upgrade this code.
Inserting and deleting data from a list is very efficient because it is not going to shift any elements in the memory, just swap a couple of pointers.
In vectors, however, inserting and deleting at the start or in the middle will shift all the elements. And if you want to add an element at the end, and there is no enough memory, then a bigger contiguous memory chunk will be allocated, and all your vector elements will be copied there.
Another thing to consider is accessing elements at random positions. Since vector is using contiguous memory, it is going to be much more cost-effective to access an element at position 100, than if you use list, because it stores elements in noncontiguous memory locations, you'll have to iterate through fist 99 elements to be able to access your 100th element.
This is a topic for a whole video, but I hope that I helped at least a little bit. 😊
Beautiful! My favorite song is Time from Pink Floyd! Great Video!
May the Force be with you.
Chain Gang of 1974 - Sleepwalking. That's also the ending song of GTA5. You should love it, I hope ;)
A šta je sa destruktorima bona?
Woah its great thnx saldina✌🏻
☺️🤗
Can you make the text in your videos a little bigger?
I already have a couple of filmed videos, but I can do that for future ones. 😊
Wow great keep it up
I really love your videos
Hi, ( sorry for my english ), first all i wish congratulation for your initiative for this course! But i have a question , why your attribute are public and not private ? usally the attributes are private and they are access with getter and setter ( information hiding ) why you don't created getter and setter. e.g. your method "getInfo" should be modified like
cout
Benvenuto! 🇮🇹
Yep, that is correct, but not everyone is going to understand that without proper explanation.
"Data hiding" principle that you're talking about is called encapsulation, and I made a video about that as well.
It is a continuation of this video.
Here is the link: ruclips.net/video/a8ZB-TPB6EU/видео.html
Btw, your English is good! 😊
Great, thanks for your videos and efforts, I have a question, at 7:22 you said that in case of declaring new object from the class we have to give it some parameters like Name, ...., so what shall be done just to declare a new object, before knowing anything about it, just like int x, is there something for that?, Many thanks in advance