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

Поділитися
Вставка
  • Опубліковано 10 чер 2024
  • 📚 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.
    The word "polymorphism" means to have many forms.
    Polymorphism usually occurs when we have multiple classes that are related by inheritance. Because of this, two derived classes can define a method that has the same name, but the different implementation (behavior)
    In this video, I'm providing a simple explanation and example of what I mentioned above.
    This is a very understandable and simple explanation, that I found on the internet, and I want to share it with you:
    If you ask a question like "What is a set?" in the forum topic "Tennis", you'll get one answer and if the forum topic is "Data structures" you'll get an entirely different answer. That's because the people who read these two topics process the same question in different ways. This is basically what polymorphism does!
    👉 Download Visual Assist here: bit.ly/VisualAssistDownload
    (Improves Visual Studio experience by quickly identifying and fixing code errors)
    ☕ 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/CodeBeauty_BuyMeACoffee
    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! ❤️😇
    C++ Object-Oriented Programming playlist:
    • C++ OOP - Introduction... - Introduction to OOP
    • C++ OOP (2020) - What ... - Constructors and class methods
    • C++ OOP - What is enca... - Encapsulation
    • C++ OOP - What is inhe... - Inheritance
    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 available in COMMENTS and on TrueCodeBeauty GIT******
    github.com/TrueCodeBeauty/Pol...
  • Наука та технологія

КОМЕНТАРІ • 180

  • @CodeBeauty
    @CodeBeauty  3 роки тому +29

    📚 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 UA-camChannel {
    private:
    string Name;
    int SubscribersCount;
    list PublishedVideoTitles;
    protected:
    string OwnerName;
    public:
    UA-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.

  • @legolas5684
    @legolas5684 3 роки тому +16

    please keep making videos!
    A brighter future waits you!

  • @mytechnotalent
    @mytechnotalent 3 роки тому +20

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

  • @olivertwist8996
    @olivertwist8996 2 роки тому +4

    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!

  • @jesusguerrero6916
    @jesusguerrero6916 2 роки тому +3

    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 !!

  • @connelly6375
    @connelly6375 3 роки тому +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!

  • @trueascendant8733
    @trueascendant8733 3 роки тому +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

  • @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.

  • @gehngis
    @gehngis 3 роки тому +12

    That is not polymorphism.
    I mean `CookingUA-camChannel` has a single function named `Practice`, so their is no need to invoke polymorphism to call `cookingUA-camChannel->Practice()`.
    Same thing for `SingersUA-camChannel`.
    So in the end you end up with 2 functions that does not have the same full name: CookingUA-camChannel::Practice and SingersUA-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 `CookingUA-camChannel::Practice(int effort)` and then when calling `cookingUA-camChannel->Practice()` you effectively use polymorphism because the compiler has to decide if you are calling `CookingUA-camChannel::Practice(int effort)` or `CookingUA-camChannel::Practice()`.
    2. Make Practice() a virtual function *and* call it through pointer to the base class.
    class UA-camChannel {
    ...
    virtual void Practice() = 0;
    ...
    }
    class CookingUA-camChannel {
    ...
    void Practice() override;
    ...
    }
    UA-camChannel *channel = new CookingUA-camChannel;
    channel->Practice();
    3. Use templates and demonstrate polymorphism without inheritance.
    template
    void call_practice(T &channel) {
    channel.Practice();
    }

    • @diezgan
      @diezgan 3 роки тому +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 3 роки тому

      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 CookingUA-camChannel() and the base class UA-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.

  • @pgallovich
    @pgallovich 3 роки тому +3

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

  • @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 !!😊

  • @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! 🤗

  • @humanR14k
    @humanR14k Рік тому +5

    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 UA-camChannel* and therefore we can only use these pointers to refer to the members that cookingYT and singersYT inherit from UA-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 😗

  • @rif5164
    @rif5164 Рік тому

    You make my life easy! Thanks, Saldina!

  • @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 :)

  • @monoman4083
    @monoman4083 3 роки тому +4

    Another great video. Many thanks..

  • @jamesperih9658
    @jamesperih9658 3 роки тому +14

    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

  • @kamceksej5524
    @kamceksej5524 13 днів тому

    beautiful video, very helpful, love it.

  • @1maruf
    @1maruf 3 роки тому +1

    *much-obliged, Sister*

  • @createrankit
    @createrankit 3 роки тому +3

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

  • @BrunoAlves-tx4gs
    @BrunoAlves-tx4gs 3 роки тому +1

    Great video. Muito bom, execelente didatica.

  • @naderhumood1199
    @naderhumood1199 Рік тому +1

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

  • @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!

  • @aw230012
    @aw230012 Рік тому +12

    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 UA-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 5 місяців тому

      Continue Playlist u find what u talk about

  • @tharushinehara4318
    @tharushinehara4318 2 роки тому

    helped me a lot!

  • @ashrsfsiliman452
    @ashrsfsiliman452 3 роки тому +2

    Thank you for your great job

  • @ermiasayele7111
    @ermiasayele7111 Рік тому

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

  • @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

  • @roros2512
    @roros2512 2 роки тому +3

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

  • @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 2 роки тому +2

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

    • @joegongamer8637
      @joegongamer8637 2 роки тому

      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.

  • @nuamaaniqbal6373
    @nuamaaniqbal6373 2 роки тому

    Thank You!

  • @juanmanueldeayanz1821
    @juanmanueldeayanz1821 3 роки тому

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

  • @Shad0wBenny
    @Shad0wBenny 2 роки тому +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!

  • @ahmadghamsari8603
    @ahmadghamsari8603 3 роки тому +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 3 роки тому

      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.

  • @madhusankawijerathne8435
    @madhusankawijerathne8435 Рік тому

    Than you!

  • @leonardopantoja7121
    @leonardopantoja7121 Місяць тому +1

    Son Interesantes tus videos.

  • @starthustling3290
    @starthustling3290 3 роки тому +1

    Thanks

  • @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?

  • @JarekAtWork
    @JarekAtWork Рік тому

    Without you, I wouldn't be here.

  • @crazycoder9356
    @crazycoder9356 Рік тому

    thanks.

  • @tejasdhule249
    @tejasdhule249 2 роки тому +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 😭

  • @charleswahome7936
    @charleswahome7936 27 днів тому

    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?

  • @anonymousbelgique7331
    @anonymousbelgique7331 2 роки тому

    thank you vm

  • @abdallahshihab3106
    @abdallahshihab3106 3 роки тому

    please keep making videos .

  • @isrza
    @isrza 2 роки тому

    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 2 роки тому

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

    • @isrza
      @isrza 2 роки тому +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 2 роки тому +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 2 роки тому

      @@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++.
      ua-cam.com/video/MZOrGXk4XFI/v-deo.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 2 роки тому

      @@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.

  • @grosucristi6599
    @grosucristi6599 Рік тому

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

  • @yashsonawane905
    @yashsonawane905 2 роки тому +2

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

    • @joegongamer8637
      @joegongamer8637 2 роки тому

      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 UA-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).

  • @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 2 роки тому +2

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

    • @KishoreG2396
      @KishoreG2396 2 роки тому +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 2 роки тому +2

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

    • @GauravSingh-ku5xy
      @GauravSingh-ku5xy 2 роки тому +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?

  • @xiaonanfan6543
    @xiaonanfan6543 Рік тому

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

  • @meisam7144
    @meisam7144 Рік тому

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

  • @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 :)

    • @kilipkumar
      @kilipkumar 9 місяців тому

      you are right , I am also doing BCA course in Gujarat . i cant speak english rather than can understand all the consepts that saldina explained .

  • @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 :)

  • @teprox7690
    @teprox7690 Рік тому

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

  • @Itsme1n1ly
    @Itsme1n1ly 2 роки тому +1

    Queen of C++

  • @ronitakhariya4094
    @ronitakhariya4094 3 роки тому +1

    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 2 роки тому

      @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 2 роки тому +1

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

  • @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.

  • @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?

  • @erende44
    @erende44 2 роки тому

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

  • @absamurai
    @absamurai 2 роки тому

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

  • @muhammadaon9147
    @muhammadaon9147 Рік тому

    std::cout

  • @Brusselsprouts2023
    @Brusselsprouts2023 2 місяці тому +1

    Saldina here!! to rescue again!!

  • @smpbih
    @smpbih 3 роки тому +2

    prelijepa si

  • @pranavkotesh.v7556
    @pranavkotesh.v7556 3 роки тому +2

    Im here from freecodecamp. And god your gorgous!

  • @asadkhan-zg3rn
    @asadkhan-zg3rn 3 роки тому

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

  • @uguryucestudent281
    @uguryucestudent281 Рік тому

    What happened if we do not use polymorphisam?

  • @siddharthasarmah9266
    @siddharthasarmah9266 3 роки тому +1

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

    • @CodeBeauty
      @CodeBeauty  3 роки тому +1

      I can try 😊
      What do you think about the sound quality of this video ua-cam.com/video/42t2-6Tqy0U/v-deo.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 3 роки тому +1

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

  • @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

  • @marathirada1199
    @marathirada1199 2 роки тому

    Pls send code of this tutorial in description

  • @arjunans5139
    @arjunans5139 5 місяців тому

    If you have watched previous videos , click 2:57

  • @debjyotinandi9140
    @debjyotinandi9140 Рік тому +1

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

  • @yashpatil9247
    @yashpatil9247 3 роки тому

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

    • @joegongamer8637
      @joegongamer8637 2 роки тому +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.

  • @konstantine3466
    @konstantine3466 2 роки тому

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

  • @rwagasanaelisa1379
    @rwagasanaelisa1379 8 місяців тому

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

  • @zihadFromPhero
    @zihadFromPhero 2 місяці тому

    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.

  • @kikosmiletv4531
    @kikosmiletv4531 Рік тому

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

  • @SyntakticSugar
    @SyntakticSugar 3 роки тому +1

    Poor Amy! I hope there isn't a real channel called Amy's Kitchen :P

  • @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 😅🥰

  • @SILX
    @SILX 2 роки тому +1

    btw, you spelt polymorphism wrong in the title

  • @nezokochaan3198
    @nezokochaan3198 2 місяці тому

    6:58 😳😳😳😳

  • @fusiontv5269
    @fusiontv5269 3 роки тому

    11:18

    • @joegongamer8637
      @joegongamer8637 2 роки тому

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

  • @amaanmajeed4068
    @amaanmajeed4068 3 роки тому +1

    John Sings

  • @GenjaOrigins
    @GenjaOrigins 2 роки тому

    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 2 роки тому

      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.

  • @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 ☺️

  • @ahasanhabibsajeeb1979
    @ahasanhabibsajeeb1979 3 роки тому

    Your pronunciation " PublishedVideoTitles" is aesthetic 😅

  • @kotinakarwak7857
    @kotinakarwak7857 3 роки тому +1

    Please pad the comment for me to understand what that line of code is doing.
    UA-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 UA-camChannel then it sets it equal to the address of cook01 via the use of the & (Address operator)

    • @joegongamer8637
      @joegongamer8637 2 роки тому

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

    • @tombarrett2306
      @tombarrett2306 2 роки тому +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 2 роки тому

      @@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**?*

  • @shoshanamofaz3012
    @shoshanamofaz3012 3 роки тому

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

  • @user-td4pf6rr2t
    @user-td4pf6rr2t Місяць тому

    Academia is Hard.

  • @tahmid1847
    @tahmid1847 Рік тому

    Ilhan are you here?

  • @RakyFX
    @RakyFX 3 роки тому +1

    Ohh how beautiful girl

  • @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

  • @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

  • @michaelvaland5467
    @michaelvaland5467 11 місяців тому +2

    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();

  • @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?

    • @saiganeshmanda4904
      @saiganeshmanda4904 Рік тому

      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)?

  • @lifehealerzr2508
    @lifehealerzr2508 10 місяців тому

    singers youtube channel does not work.