Virtual Functions in C++



Twitter ►
Instagram ►
Patreon ►
Slack ►

Series Playlist ►

BEST laptop for programming! ►
My FAVOURITE keyboard for programming! ►
FAVOURITE monitors for programming! ►

MAIN Camera ►
MAIN Lens ►
Second Camera ►
Microphone ►

Nguồn: https://chototdayroi.com

Xem thêm bài viết khác: https://chototdayroi.com/cong-nghe/


Article Categories:
Công Nghệ

Comments

  • There's no such thing as "minimal impact" in my opinion, there's impact or no impact. I'd rather avoid impact altogether. 😛

    Njul June 13, 2020 8:45 am Reply
  • Player (const std::String& name) : m_Name (name) { }
    why is the :m_Name there?
    should it now be the in "{ }"

    Also why is no return used?

    xganh zu June 13, 2020 8:45 am Reply
  • After watching this I realised how easy is Java 😂.

    Shock wave June 13, 2020 8:45 am Reply
  • Let me tell you, I've been going to school for Software Engineering, and I have taken a bunch of different languages. Not a single one of them I really understood, just got it well enough to pass the class. But ever since I've found your CPP series, it's really helped, and I think I finally "get" it. This is the first language where I'm able to code without having to look up the solution 5 minutes into trying. Thank you for this series!

    Bert N Ernie June 13, 2020 8:45 am Reply
  • you are genius

    Lokesh Kumar June 13, 2020 8:45 am Reply
  • Most of the time I've seen a tutorial about virtual functions/vtables it works pretty well to make some diagrams on paper about how it works because it's such an abstract concept that in general people, especially newbies, find a hard time trying to understand what's happening under the hood.

    JFR June 13, 2020 8:45 am Reply
  • just use a template guys

    Gunwant Jain June 13, 2020 8:45 am Reply
  • Excellent explanation. Something I'm looking for. Thank you so much.

    geekPanther June 13, 2020 8:45 am Reply
  • How did you learn C plus plus in from where

    Html Hhttmmll June 13, 2020 8:45 am Reply
  • From where did you learn C plus plus

    Html Hhttmmll June 13, 2020 8:45 am Reply
  • Please make a video on V Table and Memory allocation. I have been watching C++ playlist, your videos are very good to get concepts more clear.

    Yugant Kadu June 13, 2020 8:45 am Reply
  • Türkçe altyazı ekleyenin eline sağlık.
    Thanks to the contributor for the Turkish subtitles.

    Alp Üstün June 13, 2020 8:45 am Reply
  • Can anyone explain me
    :m_Name(name) {} ?????

    Tung Hoang June 13, 2020 8:45 am Reply
  • it's the second time you save me hours of searching while I'm studying, thanks.

    AjWy27wp w5QNaD June 13, 2020 8:45 am Reply
  • until this video, ur videos is very good. But in this video, there is so much things to uncovered and not explained. hard to cover.

    faruk okumuş June 13, 2020 8:45 am Reply
  • It is interesting that C# shows a warning when not overriding the inherited member, but C++ doesn't.

    Edgars Šturms June 13, 2020 8:45 am Reply
  • Oh nooo. Not the ugly and mostly useless these days hungarian notation. Cool vid tho

    Katniss June 13, 2020 8:45 am Reply
  • Thank you!!!

    H Robin June 13, 2020 8:45 am Reply
  • Dude you are great at explaining these things. Probably won't ever see this comment but thank you. I don't write comments a lot but I am teaching myself c++ and I've watched several of your vids and they are awesome and extremely helpful. Thanks again!

    Thomas Haug June 13, 2020 8:45 am Reply
  • Player* p = new Player();
    Entity* entity = p;
    so now entity is a pointer pointing at p(Player class)
    so when calling
    entity->GetName();
    it should be equal to
    p->GetName();
    which means the GetName() function inside the Player class is supposed to invoked
    am i not correct
    why must the virtual keyword be added to make it possible to invoke the GetName() in Player class?

    huanan KO June 13, 2020 8:45 am Reply
  • Hey Cherno, could you please make a video on the virtual table and stuff.

    Bhargav2307 June 13, 2020 8:45 am Reply
  • Did I miss the video where you explained how to initialise member variables?

    Newmaidumosa June 13, 2020 8:45 am Reply
  • Just curious, in another video of yours you state that most of the time you would want to use the stack. Why do you use the new keyword instead of doing something like "Entity e;" ?

    Randy Yee June 13, 2020 8:45 am Reply
  • Slapping like on all the vids 🙂

    Wim Matthijs June 13, 2020 8:45 am Reply
  • Thanks

    taro June 13, 2020 8:45 am Reply
  • Congrats, fellow hacker, i recognise you as one of them 'Non-pasters', have a nice journey hooking them VMT-s!

    Dafid June 13, 2020 8:45 am Reply
  • Is there any way in c++ to make a functional that takes some arguments in a class but takes other arguments in inherited class.

    For example: I have a class A and a class b inherited from class A. Class a has a function called Print(int a) and class B will have the same function Print with different variables like Print(char* b)

    Soumik Bhattacherjee June 13, 2020 8:45 am Reply
  • awesome video man

    Angel Moreta June 13, 2020 8:45 am Reply
  • i'm so confused rn

    Daniel Eccleston June 13, 2020 8:45 am Reply
  • Okay Cherno… we get it… we are dumb. You happy now?
    Guess I'll just have to watch more of your videos to understand these unexplained concepts, which I was going to anyways because you're the best teacher ever.
    😀

    Ink Fox June 13, 2020 8:45 am Reply
  • u save me dude thank you so much !!!!!!! <3333

    romain lucas June 13, 2020 8:45 am Reply
  • If you are looking for the whole code, here it is:
    #include <cstdio>
    #include <cstring>
    #include <iostream>
    using namespace std;
    struct Animal
    {
      public:
      virtual string GetName() { return "Animal"; }
    };
    struct Dog : public Animal
    {
    private:
      string m_Name;
    public:
      Dog(const string& name): m_Name(name) {}
      string GetName() override { return m_Name; }
    };
    void PrintName(Animal* animal)
    {
      cout << animal->GetName() << endl;
    }
    int main()
    {
      Animal* a = new Animal();
      PrintName(a);
      Dog* d = new Dog("dog");
      PrintName(d);
      cin.get();
      return 0;
    }

    Nogard June 13, 2020 8:45 am Reply
  • If you're confused by this video and the next video… come back to it after watching more of his videos in the playlist. They are a bit out of order.

    Zack W June 13, 2020 8:45 am Reply
  • Well this video was dog shit wtf is half this shit you typed??

    Redfrog101 June 13, 2020 8:45 am Reply
  • Can you please elaborate on the working of Vtable in the memory if you haven't done already?

    No Greater Love June 13, 2020 8:45 am Reply
  • This wouldn't have worked if you did:
    Entity e;
    Player p;

    right? I tried it and I had to use a pointer to each on the heap.

    Patrick Anon June 13, 2020 8:45 am Reply
  • So let me get this right… virtual functions are basically a way to allow a derived class to override a method from its base class so that everything stays nice and organized? So you can declare a function as virtual so that base classes won't use that function when calling an instance of their own function?

    KingUnity June 13, 2020 8:45 am Reply
  • Did he delete some videos? seems like a giant leap, but maybe i'm just stupid.

    oDismal June 13, 2020 8:45 am Reply
  • You a life saver. keep up the good work!

    Notre Monde June 13, 2020 8:45 am Reply
  • Your videos are amazing tools for learning this stuff.

    WILL D June 13, 2020 8:45 am Reply

Leave a Comment

Your email address will not be published. Required fields are marked *