C++ OOP - What is polymorphism in programming? (simple example)

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 ก.ย. 2024

ความคิดเห็น • 184

  • @CodeBeauty
    @CodeBeauty  4 ปีที่แล้ว +31

    📚 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 TH-camChannel {
    private:
    string Name;
    int SubscribersCount;
    list PublishedVideoTitles;
    protected:
    string OwnerName;
    public:
    TH-camChannel(string name, string ownerName) {
    Name = name;
    OwnerName = ownerName;
    SubscribersCount = 0;
    }
    void GetInfo() {
    cout

    • @sunilkumar-ft3nk
      @sunilkumar-ft3nk 3 ปีที่แล้ว +1

      What is the use of system (pause);.

    • @dasp125
      @dasp125 3 ปีที่แล้ว +4

      @@sunilkumar-ft3nk pauses the program so it doesn’t display the directory address, exited with code 0 and press any key in the console after your programs output.

    • @sunilkumar-ft3nk
      @sunilkumar-ft3nk 3 ปีที่แล้ว

      @@dasp125 thank 👍👍

    • @ManMartin
      @ManMartin 3 ปีที่แล้ว

      Why it is called protected instead shared for example? Cause it is a property shared by all the objects crested frm the origen class. I dont undestand the names, like virtual.

  • @mytechnotalent
    @mytechnotalent 4 ปีที่แล้ว +24

    Like the step-by-step breakdown this is a tough subject and you made it quite easy. Well done Saldina!

  • @jesusguerrero6916
    @jesusguerrero6916 2 ปีที่แล้ว +4

    I'm a student's software engineer, and your videos are very helpfully to begin in C++ OPP, thanks for this content, I´m sure You help more than one person.
    Greetings from Mexico !!

  • @gehngis
    @gehngis 4 ปีที่แล้ว +17

    That is not polymorphism.
    I mean `CookingTH-camChannel` has a single function named `Practice`, so their is no need to invoke polymorphism to call `cookingTH-camChannel->Practice()`.
    Same thing for `SingersTH-camChannel`.
    So in the end you end up with 2 functions that does not have the same full name: CookingTH-camChannel::Practice and SingersTH-camChannel::Practice.
    It is not polymorphism, it is just scoping.
    Casting a pointer of a derived class to a base class is not polymorphism.
    Calling a function a the base class (CheckAnanlytics) through pointer to the base class is still not polymorphism, even if the pointer points to an instance of the derived class.
    To demonstrate polymorphism, you need examples where you are missing a piece of information at the call site.
    You could have done:
    1. Have multiple functions with same name (and scope) but different parameters. This could be done by introducing `CookingTH-camChannel::Practice(int effort)` and then when calling `cookingTH-camChannel->Practice()` you effectively use polymorphism because the compiler has to decide if you are calling `CookingTH-camChannel::Practice(int effort)` or `CookingTH-camChannel::Practice()`.
    2. Make Practice() a virtual function *and* call it through pointer to the base class.
    class TH-camChannel {
    ...
    virtual void Practice() = 0;
    ...
    }
    class CookingTH-camChannel {
    ...
    void Practice() override;
    ...
    }
    TH-camChannel *channel = new CookingTH-camChannel;
    channel->Practice();
    3. Use templates and demonstrate polymorphism without inheritance.
    template
    void call_practice(T &channel) {
    channel.Practice();
    }

    • @diezgan
      @diezgan 4 ปีที่แล้ว +3

      I agree - without a virtual function (pure or not) in a base class and its overriding in a derived class(es), there is no dynamic polymorphism.

    • @kotinakarwak7857
      @kotinakarwak7857 4 ปีที่แล้ว +1

      Tutor added (simple example) in title and hope she adds the features you mention above in the upcoming lesson to cement the knowledge to us beginners.
      Thanks for pointing this out too since reading through your suggestion easily explains what I have learnt so far and where I should go to next.

    • @jamesperih9658
      @jamesperih9658 3 ปีที่แล้ว +2

      I get you on #2 and #3, but either #1 you meant CookingTH-camChannel() and the base class TH-camChannel()... or, aren't you just describing overloading?

    • @gehngis
      @gehngis 3 ปีที่แล้ว +2

      @@jamesperih9658 Yes, #1 is function overloading. But function overloading is also a subtype of polymorphism, named "ad hoc polymorphism" (en.wikipedia.org/wiki/Ad_hoc_polymorphism).
      I agree though that in day to day developer talks, polymorphism is not used to describe overloading.

    • @jvsnyc
      @jvsnyc 3 ปีที่แล้ว

      @@gehngis I strongly agree. Some pedants describe overloading as compile-time-polymorphism or early binding. Many of these pedants are brilliant, and have much to teach me, so I have taken to referring to overloading as compile-time-polymorphism or early-binding polymorphism, but I did OOPS for years without ever describing overloading as polymorphism, we always meant the virtual-method-in-base-class getting overridden behavior via. VTable as the 'simple' definition of polymorphism.
      What she shows is nice, but I normally would not use the term polymorphism there.

  • @legolas5684
    @legolas5684 4 ปีที่แล้ว +16

    please keep making videos!
    A brighter future waits you!

  • @roros2512
    @roros2512 3 ปีที่แล้ว +4

    why do you use pointers to get analyitics? shouln't be the same to use a method? thanks Saldina

  • @ronitakhariya4094
    @ronitakhariya4094 3 ปีที่แล้ว +2

    why did we use pointers instead of just using
    cookingYtChannel.CheckAnalytics();
    ?
    why create a *yt1 for it?

    • @KishoreG2396
      @KishoreG2396 3 ปีที่แล้ว +1

      That's what polymorphism is. The pointer was used because we want to access the derived class instance through a base class pointer.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      @Ronit Akhariya Maybe it's because passing by value won't give you the original results from the CheckAnalytics method. Pointers let you pass by reference which means you can access the original properties of the child object and modify it. Without pointers, you'll affect its copy instead of the original object. Hopefully, I'm correct about this cause I'm still waiting for K G. to confirm if this reasoning is correct.

    • @KishoreG2396
      @KishoreG2396 3 ปีที่แล้ว +1

      @@joegongamer8637 Check the comments of the previous thread. I posted a reply

  • @Shad0wBenny
    @Shad0wBenny 3 ปีที่แล้ว +3

    Hi Saldina! Just a quick observation;
    In your title for Video 5, polymorphism is misspelled. Your "editor" (wink) snuck in the letter "a."
    Wow, today is the one year anniversary of when the course was posted,
    meaning, that misspelling has been up there the entire time.
    Now now Saldina, that's. just. criminal. :-) lol!

  • @pgallovich
    @pgallovich 4 ปีที่แล้ว +3

    I’m so glad I followed you from Brads channel. Love this content! So important for me at this time. Thank you!

  • @yashsonawane905
    @yashsonawane905 3 ปีที่แล้ว +2

    What is the use of pointer here? I really didn't get it. Can you explain it, please?

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      I don't know if she explained it well enough but I think it's for the parent class to access the same method from the child class. You need the Practice method in the parent class cause that's how you can have your child classes get the same method but different implementation. It doesn't make sense if the subclass gets the Practice method while the superclass doesn't cause it's like where did the children get their traits from(they have to get it from their parents). Using her example, let's say you want to store a cooking YT channel(subclass) in a YT channel(superclass). If you try to call the Practice method on this superclass, it won't call the practice method from the cooking channel subclass. Instead, it would call the practice method from the YT channel superclass. This provides an inaccuracy(logical error). The way to fix this is to have the parent object be a pointer object *AND* having the parent method has the code word: virtual(I have yet to figure out why that is). This would let the parent object point to the practice method in the cooking channel subclass, thus, being able to print what a YT cook should practice(instead of what a default TH-camr should practice).
      Another reason is to pass by reference. If you want to access the original object and modify its properties, then pointers are a must. Hopefully, this explanation helps(idk whether you already found your answer or not).

  • @Dani-mp2we
    @Dani-mp2we 3 ปีที่แล้ว +1

    I dont understood. Why do you deal with pointers in this video? Is that extra? Or are there in context with the polymorphismus?

    • @KishoreG2396
      @KishoreG2396 3 ปีที่แล้ว +2

      The reason we use pointers is because we are trying to access the functionality through the base class. So we create a base class pointer, but we set it equal to the address of a derived class instance. Thus, the same pointer can be used to refer to any derived class instance. That's what polymorphism is.

  • @teprox7690
    @teprox7690 2 ปีที่แล้ว

    CheckAnalytics is public for both subclasses. Why you need the pointers?

  • @erende44
    @erende44 2 ปีที่แล้ว

    maybe not so important but you have a typo in the title of this video :) Thank you for your work!

  • @indiangigachad777
    @indiangigachad777 3 ปีที่แล้ว

    Hey Saldina, I am going through the book C++ Primer Plus 6th Ed....im stuck on chapter 12-13 dynamic memory alloc, and inheritance...how would you push through in times when you get stuck on a concept?

  • @Itsme1n1ly
    @Itsme1n1ly 2 ปีที่แล้ว +1

    Queen of C++

  • @crazycoder9356
    @crazycoder9356 2 ปีที่แล้ว

    thanks.

  • @anonymousbelgique7331
    @anonymousbelgique7331 2 ปีที่แล้ว

    thank you vm

  • @madelinelopez2035
    @madelinelopez2035 ปีที่แล้ว

    Hi Saldina - Love your content! 🙂Quick question: what is the benefit to using the "pointer to derived class method" approach over just directly calling the "derivedClass.method()"? In your last example, my first instinct was to use singersYtChannel.CheckAnalytics(). Why use the pointer instead?

    • @SaiGanesh314
      @SaiGanesh314 ปีที่แล้ว

      I am not an expert but the way I see it, the second method she explained instantiates two objects (of each derived class) from the same superclass (or parent class) rather than invoking the CheckAnalytics() function for two objects defined from each derived class separately.
      So, instead of instatiating objects from child classes separately, the second method did it from instantiation from the one single parent class itself.
      The reason I wondered the same question as you did is because I thought -
      This second way of implementing polymorphism using pointers would also require you to create two separate objects. How is it any better than the first implementation (the one without using pointers)?

  • @nezokochaan3198
    @nezokochaan3198 6 หลายเดือนก่อน

    6:58 😳😳😳😳

  • @shoshanamofaz3012
    @shoshanamofaz3012 3 ปีที่แล้ว

    Polymorphic code like hackers use? It’s hard to detect. Great for creating a back door in the network. Bad stuff

  • @kotinakarwak7857
    @kotinakarwak7857 4 ปีที่แล้ว +1

    Please pad the comment for me to understand what that line of code is doing.
    TH-camChannel *yt1 = &cook01; //assign a pointer to a base class enitiy to an instance of its derived object address.

    • @tombarrett2306
      @tombarrett2306 3 ปีที่แล้ว +1

      This line of code creates a pointer for the Type TH-camChannel then it sets it equal to the address of cook01 via the use of the & (Address operator)

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      @@tombarrett2306 The next question I have is if it gives the same result as without using pointers?

    • @tombarrett2306
      @tombarrett2306 3 ปีที่แล้ว +1

      @@joegongamer8637 So in response to your question if I understand what you're asking. Pointers are used for referencing things so you can point a pointer at a location in memory and access it. However a pointer is only a reference what it points to determines what will happen when it is dereferenced. The reason to use pointers is it gives you better control of memory.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      @@tombarrett2306 Thanks for trying to understand and explain more about pointers. Pointers are a hard lesson to learn as it took a long while for me to understand them well. I plan on relearning them in my spare time.
      *What I meant to ask was if she didn't use pointers, would the result still be the same at **13:48**?*

  • @RakyFX
    @RakyFX 4 ปีที่แล้ว +1

    Ohh how beautiful girl

  • @anschoudhary1376
    @anschoudhary1376 24 วันที่ผ่านมา

    TH-camChannel1 * cooking = new CookingyouTubeChannel(“amykitchen”, “Amy”);
    TH-camChannel2 * singing = new SingingyoutbeChannel1 (“john sings”, “john”);
    Cookingyoutube-> practice();
    singingyoutube->practice(); //this shows how we we can use one interface and you "many forms"

    • @anschoudhary1376
      @anschoudhary1376 24 วันที่ผ่านมา

      practice has to virtual in the base class

  • @jamesperih9658
    @jamesperih9658 3 ปีที่แล้ว +15

    Wouldn't it be polymorphism if the base class had a .Practice method, but the derived classes implemented them differently?

    • @jimena6194
      @jimena6194 2 ปีที่แล้ว +1

      thats polymorphism as well she has an example of that at the end of her video explaining virtual functions

  • @dalerobinson3091
    @dalerobinson3091 3 ปีที่แล้ว +18

    Hello Saldina. Your videos are very well done, and informative. Would you make a video explaining the 'Copy Constructor' when, and why it is used and needed? Thanks in advance.

  • @giovannimagni3493
    @giovannimagni3493 3 ปีที่แล้ว +9

    Great Saldina !! Thx you so much for your effort.
    Just a little question about your example. To be honest, I'm not understanding rightly the reason of the pointer used there.
    I mean that same result could be get using derived class method directly. The derived classes are already instanced and yt1->CheckAnalytics() = cookingYtChannel.CheckAnalytics().
    Am I wrong ? What's the rule ?

    • @dynamic_dharsan3_1xor19
      @dynamic_dharsan3_1xor19 3 ปีที่แล้ว +2

      I have the same doubt? Contact me if u got correct answer intimate me on discord @iAmDharsan#6700.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      I'm confused as well. Although this video is a good tutorial, I don't think she explained why we have to use pointers. If I were to guess, it might be to call the subclass methods from the superclass. That way, you don't have to type in different names from the subclasses. I might be incorrect but I think you would get the same results either way. However, I feel like it doesn't add up for the example she used because I don't see how using pointers would be more convenient than without them.

    • @jimena6194
      @jimena6194 2 ปีที่แล้ว +1

      while that is correct a better example is at the end of her video on virtual functions.

  • @olivertwist8996
    @olivertwist8996 2 ปีที่แล้ว +9

    This is honestly the best conetnt on YT for learning c++. My professor is completely useless and makes everything harder. Sometimes I spend 3 hours trying to understand a concept, then I find one fo your videos and I understand it instantly.
    P.S. When I watch your videos I never skip the ads but I let them run for as long as they run. I know that adsense pays youtubers more when ads are watched in full (or something like that :D ), anyway, THANK YOU!

  • @humanR14k
    @humanR14k ปีที่แล้ว +7

    For people who didn't understand why Saldina used the pointer at the end of the video, well, I will explain the difference.
    The only limitation in using *yt1 and *yt2 instead of cookingYt and singersYt is that both *yt1 and *yt2 are of type TH-camChannel* and therefore we can only use these pointers to refer to the members that cookingYT and singersYT inherit from TH-camChannel. so if we were to call the private function from these derived class (The Function made in these classes), we would use "cookingYT or SingersYT" instead of *yt1 and *yt2.
    thx 😗

    • @troyeer
      @troyeer 2 หลายเดือนก่อน

      so, in this case, it really didnt matter which one to use right? If we used cookingytchannel.CheckAnalytics(), it should work fine?

  • @trueascendant8733
    @trueascendant8733 4 ปีที่แล้ว +12

    Very much appreciate your time and energy you put into your video’s I’m still an absolute beginner, could you please do a tutorial on complete beginners for just C programming language, I love 💓 the way you teach you have the best videos on c++ that I’ve seen so far thank you x

  • @connelly6375
    @connelly6375 4 ปีที่แล้ว +10

    great series, I have been doing C development for a long time and have always been intimidated by C++ but am loving it now!

  • @scalemodelsworld
    @scalemodelsworld 3 ปีที่แล้ว +7

    "I'm going to copy that, so that I don't make a typo"
    Introduces a typo with the copy :))
    Nice and informative videos, btw :)

  • @aw230012
    @aw230012 ปีที่แล้ว +14

    It's a good demonstration of polymorphism but you can't demonstrate true polymorphism without using the virtual keyword for dynamic binding. A better example would be to have the Practice function defined in the TH-camChannel class as virtual or pure virtual, then override the Practice function in the child classes. Now, you can use Liskov Substitution to store the child classes as their parent, and still invoke the Practice method with polymorphism due to Practice being defined as virtual or pure virtual. I love your C++ series and thought I'd give some feedback on this one. I forward my students to your page all the time!

    • @mes2009
      @mes2009 8 หลายเดือนก่อน

      Continue Playlist u find what u talk about

  • @TheDarkLordSpaniard
    @TheDarkLordSpaniard 3 ปีที่แล้ว +6

    Hello! Why do we use pointers instead of for example singersYtChannel.CheckAnalytics(); since it's public already. I might've missed something.
    Cheers for the course!

    • @KishoreG2396
      @KishoreG2396 3 ปีที่แล้ว

      The pointers are what polymorphism allows us to do: access the derived class through a pointer of the base class.

    • @GauravSingh-ku5xy
      @GauravSingh-ku5xy 3 ปีที่แล้ว +2

      @@KishoreG2396 But why? It's much easier to just type in object name and then invoke the method directly.

    • @KishoreG2396
      @KishoreG2396 3 ปีที่แล้ว +5

      @@GauravSingh-ku5xy Because in some cases we want to use more generic behavior.
      For example, let's say you have an Animal class, and all it's derived classes are types of animals like Dog, Cat, etc. If you have an Animal*, you can store any animal in it, so you don't need to worry about it specifically being a Dog, Cat, or something else. You can perform a generic action on an Animal, like Animal::eat() or Animal::walk() without knowing the derived class type.
      Also, you can store an array of multiple different Animal types if it is an array that stores Animal. Let's say you have an array that represents a zoo (Animal zooAnimals[5] ). You could store different types of animals, like 1 Zebra, 2 Giraffes, and 2 Lions. Whereas if the type of the array was just a specific object type, you could only store that single object type like Dog or Cat.

    • @GauravSingh-ku5xy
      @GauravSingh-ku5xy 3 ปีที่แล้ว +2

      @@KishoreG2396 I got it man. That was a good explanation.

    • @GauravSingh-ku5xy
      @GauravSingh-ku5xy 3 ปีที่แล้ว +2

      @@KishoreG2396 Also, so here we are seeing polymorphism in an object (because same pointer can also point to a different object) and also in its function(The function has same name but different implementation). Right?

  • @tejasdhule249
    @tejasdhule249 3 ปีที่แล้ว +2

    This is my bad luck that I have visited this channel so late .... If I had visited this OOPs series an year before then definitely today I will be working with India's one of best Service Based Wipro Software Company 😓...... Because last year I got a chance for interview in Wipro Software LTD. And the interviewer asked me to implement these OOPs concepts with C++ code examples ..... But I was unable to do so because my concepts were not clear 😭..... Saldina Why don't you meet me an year before 😭

  • @sayantanpaul6174
    @sayantanpaul6174 3 ปีที่แล้ว +4

    Hey Saldina, thank you for providing such great C++ content. Very helpful for non-cs students to enter into programming. Please keep posting more videos. THANK YOU CODE BEAUTY !!😊

  • @kwayssa
    @kwayssa 3 ปีที่แล้ว +3

    Making the pointer type a base Class type, enables the pointer to only access the functions in that base class only, but making the pointer type a derived class type, enables the pointer to access functions in both classes, base class & that derived class..

    • @jvsnyc
      @jvsnyc 3 ปีที่แล้ว +1

      I am not sure, but I normally would only use the term polymorphism to refer to when a base class method gets overridden in one or more derived classes, and calls to that method defined in the base class "automagically" get the derived class behavior due to being defined as virtual in the base class thru the use of VTables. While it is true that the derived class members can also add new methods that aren't in the base class, unless the overridden methods call these in the derived class, that isn't using the base class polymorphically. In Java, all of the methods of a class are 'virtual' by default, placed in a VTable, and get this overriding behavior automatically, unless marked 'final' (Java doesn't even have a virtual keyword), but C++ doesn't do this automatically.
      Had she been calling ->practice() thru a base class pointer then this would have been using polymorphism, but that wouldn't even work here unless it was defined in the base class, perhaps as abstract, and virtual. Checking this now. Oops. Visual Studio wants an update, I'll be back after the reboot!

  • @monoman4083
    @monoman4083 4 ปีที่แล้ว +4

    Another great video. Many thanks..

  • @amalkallarakkal9487
    @amalkallarakkal9487 28 วันที่ผ่านมา +1

    looking for that johnny sinns comment 5:17 looks like Im the only one .. am i cooked?

  • @pranavkotesh.v7556
    @pranavkotesh.v7556 3 ปีที่แล้ว +2

    Im here from freecodecamp. And god your gorgous!

  • @thatonichan
    @thatonichan 2 ปีที่แล้ว +1

    Amy reminds me of the owner of Amy's bakery from Kitchen Nightmares

  • @BetulKaplan
    @BetulKaplan 3 ปีที่แล้ว +4

    your video layout is helping me to understand a lot and the way you explain is very clear. keep it up!

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +3

      I'm happy to help, thanks! 🤗

  • @createrankit
    @createrankit 4 ปีที่แล้ว +3

    Great video lectures, hope you teach development part in c++ .

  • @leonardopantoja7121
    @leonardopantoja7121 4 หลายเดือนก่อน +1

    Son Interesantes tus videos.

  • @JarekAtWork
    @JarekAtWork ปีที่แล้ว +1

    Sometimes I think you're not real. No computer scientist changes their clothes so often.

    • @CodeBeauty
      @CodeBeauty  ปีที่แล้ว

      Hahaha, very much real and fancy 😅🥰

  • @Brusselsprouts2023
    @Brusselsprouts2023 5 หลายเดือนก่อน +1

    Saldina here!! to rescue again!!

    • @CodeBeauty
      @CodeBeauty  5 หลายเดือนก่อน

      🥰🥰

  • @ruchitechster
    @ruchitechster ปีที่แล้ว +1

    Hey Saldina i'm from India, in my 2nd year of BCA i have C++ but i can't understand anything. Your videos are very easy to understand and so helpful, Thanks a lot :)

  • @christygeorge9938
    @christygeorge9938 2 ปีที่แล้ว +1

    Hi Saldina,
    Your videos are really helpful,
    In this video ,inside the constructor, you haven't initialized the list type, shouldn't we ideally initialize all the variables, in constructor?
    Or else it might give run time issues in our program right

  • @michaelvaland5467
    @michaelvaland5467 ปีที่แล้ว +3

    hey so why can't we just call the check analytics method without having to create a pointer of the base class and calling it directly on the derived class like: cookingYtChannel.checkAnalytics();

  • @starthustling3290
    @starthustling3290 3 ปีที่แล้ว +1

    Thanks

  • @ashrsfsiliman452
    @ashrsfsiliman452 3 ปีที่แล้ว +2

    Thank you for your great job

  • @ordinary_man_84
    @ordinary_man_84 หลายเดือนก่อน

    everything seems to be clear, but it's still difficult to understand the essence. If I want to use polymorphism when I need it, then my brain will break)

  • @kikosmiletv4531
    @kikosmiletv4531 ปีที่แล้ว

    new subscriber here, how can you be so intelligent and very pretty at the same time?

  • @smpbih
    @smpbih 4 ปีที่แล้ว +2

    prelijepa si

  • @charleswahome7936
    @charleswahome7936 4 หลายเดือนก่อน

    Great video. If I may ask, there is this concept that method overriding must happen for us to implement polymorphism. And a virtual function must be declared in the base class so that the overriding can be done in the child classes. Is it a must we do overriding of methods in the child classes? Or must we create the virtual function in the baseclass to make it abstract?

  • @naderhumood1199
    @naderhumood1199 2 ปีที่แล้ว +1

    Amazing channel......Thanks v much.

  • @SILX
    @SILX 3 ปีที่แล้ว +1

    btw, you spelt polymorphism wrong in the title

  • @zihadFromPhero
    @zihadFromPhero 6 หลายเดือนก่อน

    is that actually polymorphism ??
    the two function is independent on their own way. they are declared in the 2 independent derived class.
    in my knowledge polymorphism is a process to override the data. so that compiler can handle different function with same name and decide that what function should run.

  • @1maruf
    @1maruf 3 ปีที่แล้ว +1

    *much-obliged, Sister*

  • @rwagasanaelisa1379
    @rwagasanaelisa1379 ปีที่แล้ว

    you speak understandable language
    but i request you to do mre examples for better understanding

  • @arjunans5139
    @arjunans5139 9 หลายเดือนก่อน

    If you have watched previous videos , click 2:57

  • @ahmadghamsari8603
    @ahmadghamsari8603 4 ปีที่แล้ว +1

    I am so glad to see your page accidentally! You are a very good teacher.
    Do you have any idea about using C++ on visual studio for programming micro controllers such as those are ARM based?

    • @connelly6375
      @connelly6375 4 ปีที่แล้ว

      It is possible to program for MCU's in visual studio but it can be hard to setup, but it is possible. You can use STM32CubeIDE to develop C++ for ST MCU's, or Atmel Studio for Atmel MCU's, Atmel Studio looks almost identical to visual studio while STM32CubeIDE is based on eclipse.

  • @kamceksej5524
    @kamceksej5524 4 หลายเดือนก่อน

    beautiful video, very helpful, love it.

  • @uguryucestudent281
    @uguryucestudent281 2 ปีที่แล้ว

    What happened if we do not use polymorphisam?

  • @mercynik2019
    @mercynik2019 ปีที่แล้ว

    why you made everything so complicated like its hard to understand for a beginner in oops like me ..

    • @CodeBeauty
      @CodeBeauty  ปีที่แล้ว +1

      There are 4 videos prior to this one that you should watch. This is part 5. If you watch those video then this should be easy to understand 🤔💡

    • @mercynik2019
      @mercynik2019 ปีที่แล้ว

      @@CodeBeauty ohh thanks i will check them for sure , operator overloading type of polymorphism is too difficult for me
      & I'm searching for it and just find your video...... Thanks for your reply ☺️ hope this will helps me to find 😊

    • @CodeBeauty
      @CodeBeauty  ปีที่แล้ว +1

      @@mercynik2019 check out object-oriented programming playlist on my channel, n watch it from beginning, it goes step by step-by-step 😃

    • @mercynik2019
      @mercynik2019 ปีที่แล้ว

      @@CodeBeauty Got it, thanks ☺️

  • @BrunoAlves-tx4gs
    @BrunoAlves-tx4gs 4 ปีที่แล้ว +1

    Great video. Muito bom, execelente didatica.

  • @JarekAtWork
    @JarekAtWork ปีที่แล้ว

    Without you, I wouldn't be here.

  • @ChristopherBruns-o7o
    @ChristopherBruns-o7o 4 หลายเดือนก่อน

    Academia is Hard.

  • @tahmid1847
    @tahmid1847 ปีที่แล้ว

    Ilhan are you here?

  • @madhusankawijerathne8435
    @madhusankawijerathne8435 ปีที่แล้ว

    Than you!

  • @fxsurgeon1
    @fxsurgeon1 2 ปีที่แล้ว +1

    Hi, thanks for your great content. Could you explain why you used pointers to the base class instead of invoking the CheckAnalytics method directly from the objects?

    • @ddddd1687
      @ddddd1687 2 ปีที่แล้ว

      Hi have you found any answer to your question? Because I am wondering the same thing 😂

    • @fxsurgeon1
      @fxsurgeon1 2 ปีที่แล้ว

      @@ddddd1687 I moved to Python and feel much happier lol

    • @ddddd1687
      @ddddd1687 2 ปีที่แล้ว

      Hahahah 🤣 OK thanks

    • @day4834
      @day4834 2 ปีที่แล้ว

      Hi, I believe this was just for learning purposes, so that we know that a derived class can be called via a pointer in the bases class and a function can be invoked using such pointer.

    • @ddddd1687
      @ddddd1687 2 ปีที่แล้ว

      @@day4834 Hi ,thank you for your answer :)

  • @GenjaOrigins
    @GenjaOrigins 3 ปีที่แล้ว

    cpp overriding vs overloading thats annoying. I thought i knew but clearly i messed things up.
    There is something i that connects that but its different damn.
    Polymorphism is...
    -CompileTime "Static Polymorphism" e.g method overloading
    -RunTime "Dynamic Polymorphism" e.g function Overiding
    But Overloading is either
    -Operator Overloading _Operator overloading is a compile-time polymorphism in which a standard operator is overloaded to provide a user-defined definition to it.
    -Function Overloading _Function overloading is also a type of compile-time polymorphism which can define a family of functions with the same name. The function would perform different operations based on the argument list in the function call. The function to be invoked depends on the number of arguments and the type of the arguments in the argument list.

    • @GenjaOrigins
      @GenjaOrigins 3 ปีที่แล้ว

      Method is a bit different from function but we need to say its the same thing. This example that you are using i think its function overriding so its not polymorphim but a type of polymorphism. I think thats what i need understand cause its complicated xd. So i guess polymorphism is just an idea an ability of an object to have many forms maybe and it has different types.

  • @amaanmajeed4068
    @amaanmajeed4068 3 ปีที่แล้ว +1

    John Sings

  • @siddharthasarmah9266
    @siddharthasarmah9266 4 ปีที่แล้ว +1

    Can you please increase your video sound. Really like your tutorials

    • @CodeBeauty
      @CodeBeauty  4 ปีที่แล้ว +1

      I can try 😊
      What do you think about the sound quality of this video th-cam.com/video/42t2-6Tqy0U/w-d-xo.html
      Is it any better? 🤔
      I tried to increase the sound a little bit in that video, but I didn't want to increase it too much, because then you can hear my air conditioner buzz in the background 😒

    • @siddharthasarmah9266
      @siddharthasarmah9266 4 ปีที่แล้ว +1

      @@CodeBeauty yah the second one is much better😃😄

  • @muhammadaon9147
    @muhammadaon9147 ปีที่แล้ว

    std::cout

  • @382946rthu
    @382946rthu 2 ปีที่แล้ว

    Probably wouldn't have been a bad idea to show what happens when the derived class is cast back to the base class or wait practice is missing from the base class. To be polymorphic shouldn't the base class also have had a practise method?

  • @noorallahpayanda
    @noorallahpayanda 3 ปีที่แล้ว +1

    why do you not have a video for the structure in c++

    • @CodeBeauty
      @CodeBeauty  3 ปีที่แล้ว +1

      Hahaha, I just didn't find time to create it so far. Thanks for showing interest 🤗

    • @noorallahpayanda
      @noorallahpayanda 3 ปีที่แล้ว

      @@CodeBeauty thank you from your response

  • @meisam7144
    @meisam7144 ปีที่แล้ว

    Why did you define pointers to access CheckAnalytics? Couldn't you access them through the already defined objects? Great videos btw...

  • @ahasanhabibsajeeb1979
    @ahasanhabibsajeeb1979 3 ปีที่แล้ว

    Your pronunciation " PublishedVideoTitles" is aesthetic 😅

  • @konstantine3466
    @konstantine3466 3 ปีที่แล้ว

    Polymorphism... As say in our Odessa: explain kroz dupe. Oh, women. Saldina, you're so bloody irresistible!

  • @xiaonanfan6543
    @xiaonanfan6543 2 ปีที่แล้ว

    pls can you make some middle sized C++ Project that we can use and practice the C++ knowleadge we leaned from you,thanks.

  • @grosucristi6599
    @grosucristi6599 2 ปีที่แล้ว

    At 13:20 why did you use pointers to call a method from base class if you can do it directly from derived class?

  • @asadkhan-zg3rn
    @asadkhan-zg3rn 3 ปีที่แล้ว

    ma'am can you please make tutorials of JavaFX..!!

  • @rif5164
    @rif5164 ปีที่แล้ว

    You make my life easy! Thanks, Saldina!

  • @ermiasayele7111
    @ermiasayele7111 ปีที่แล้ว

    thank you very much I learn much much in a few minuet

  • @abdallahshihab3106
    @abdallahshihab3106 3 ปีที่แล้ว

    please keep making videos .

  • @marathirada1199
    @marathirada1199 2 ปีที่แล้ว

    Pls send code of this tutorial in description

  • @absamurai
    @absamurai 2 ปีที่แล้ว

    Hi! There is a typo in the video caption (polymorphisAm).

  • @juanmanueldeayanz1821
    @juanmanueldeayanz1821 4 ปีที่แล้ว

    Gracias Saldina!
    ¿Harás vídeos sobre Software Architecture and Design Patterns más adelante?
    Saludos desde España.

  • @tharushinehara4318
    @tharushinehara4318 2 ปีที่แล้ว

    helped me a lot!

  • @nuamaaniqbal6373
    @nuamaaniqbal6373 2 ปีที่แล้ว

    Thank You!

  • @yashpatil9247
    @yashpatil9247 3 ปีที่แล้ว

    why there is a need to initialize constructor of parent class in every inherited class

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว +1

      If I understand what you're trying to ask, it's required for the subclass' constructor to be initialized from the superclass. It's kinda like without the child having inherited traits from the parents, the child wouldn't exist.

  • @jurekpacewicz2693
    @jurekpacewicz2693 2 ปีที่แล้ว +2

    Hi Saldina, I enjoy your lectures. I have got some suggestions for you to master your presentation. The fundamental thing is that you use (unfortunately as many others) the default font size, which is definitely too small. It has to be at least 2 points more, if possible even 3 points. Not everyone has got falcon's eyes. The most important thing is a screen organisation. You put an enormous big banner with your IT addresses. That takes a lot of screen space. That info banner should not be even there or much, much smaller. I enjoy seeing you "Pretty Woman" with your beautiful long hair. Unfortunately it doesn't help to concentrate on lectures, in contrary it distracts an attention a lot. Again it is much, much too big! Try to see your lectures on different screens, from smartphones through notebooks ending on big 30" - 50" screens. The knowledge you give should be given in the easiest and the most readable way. The black screen is the worst readable solution!!!
    I wish you would be the best.
    Zdrowia Radosci i samych PRZYJEMNOSCI from Poland. Jurek, your fun

  • @fusiontv5269
    @fusiontv5269 3 ปีที่แล้ว

    11:18

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      Yeah, I think using pointers for polymorphism should be a burning question for her OOP in C++ video.

  • @isrza
    @isrza 3 ปีที่แล้ว

    Using pointer is exactly what I was looking for. As a student with java experience I stuck about using different type of objects derived from a base class in a single function. Using parameter as a pointer of base class in function is what I needed, thank you so much.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      Do you know why she uses pointers in this video? I ask because I don't think she explained why.

    • @isrza
      @isrza 3 ปีที่แล้ว +1

      @@joegongamer8637 She shows how the polymorphism works in C++. Imagine you have a program where it does the exact same function for for all objects but the implementation of these functions is different. In this case you would have create a separate function for each object, but with polymorphism you can use parent class as a type ( pointer form for c++) and then use it for all derived classes.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว +1

      @@isrza I think I somewhat get what you mean. She did make a good C++ video on polymorphism. However, I still don't think she explains clearly why we would use pointers in this video. So, if she doesn't want to give a better understanding of why use pointers for polymorphism, then can you please provide me a clearer explanation?

    • @isrza
      @isrza 3 ปีที่แล้ว

      @@joegongamer8637 well let me give you an explanation about in practice. Imagine we have a a game where you can shoot enemies friends and object ( boxes and etc.). But I you might have guessed each object will give you a different reaction ( enemy will lost health, box will collapse, fried will also lost health but tell you be careful). In this case all these objects have a property call getHit, but have different implementation. But in order to get this property work our bullet objet have to call this property whenever it meet with an object which has a properly getHit. But we don't want to have a long if else statements. Instead we want to use an argument which can represent all hitable objects. Bu beaucoup of the syntax kr nature of C++ we cannot give a parent call as arguments and pass ther child class in use. In order use use polymorphism we have to pass that argument as a pointer, this is something about nature of c++.
      th-cam.com/video/MZOrGXk4XFI/w-d-xo.html . This the reference of my explanation. You can take a look if you want. It is c# but focus on the concept than language. As you can see in c# we don't use pointers, neither in java. So usage of pointers is only about syntax of C++.

    • @joegongamer8637
      @joegongamer8637 3 ปีที่แล้ว

      @@isrza Although I appreciate your efforts in your explanation, I unfortunately still somewhat get what you mean. What I can understand is how it can make you write less code when you have a lot of objects, loops, and if/else statements to deal with. If using pointers is the only way for the superclass to access the same method from the subclass(ex. Animal tries to call speak() to print out the respected animal sound depending on the type of subclass animal), then I can understand. There are some cases where using pointers is just a personal choice. Her example @13:48 would print the same results even without pointers, just a different way of coding it. The same goes for the GetInfo method because you can also do Animal test = daDog; test.GetInfo(); to get the information about daDog object. If you're dealing with let's say multiple Animal objects, you can create an Animal array. The only things I can understand using pointers when it comes to polymorphism are if it's the *only way* for the parent object to access the same method from its child object OR for the parent object to pass the child object by reference, which would allow the programmer to get and modify its original properties. Other than that, I don't see why else one should use pointers for polymorphism.
      Thank you for posting the link, I'll see if I can check it out as I'm also interested in C#, game dev, and gaming.

  • @ivans7
    @ivans7 ปีที่แล้ว

    you complicated the thing. I still don't understand.. :(

  • @azizprimbetov2745
    @azizprimbetov2745 ปีที่แล้ว

    Hello Saldina i have a question why do i need to use pointer checkanalytics method is public we can check it directly using object ytb.checkqualiyt() method

  • @lifehealerzr2508
    @lifehealerzr2508 ปีที่แล้ว

    singers youtube channel does not work.