Skip to content

Instantly share code, notes, and snippets.

@chichunchen
Created April 19, 2019 22:24
Show Gist options
  • Save chichunchen/4c7f052ed4ee64ebd145d3875fa8fc13 to your computer and use it in GitHub Desktop.
Save chichunchen/4c7f052ed4ee64ebd145d3875fa8fc13 to your computer and use it in GitHub Desktop.

Revisions

  1. chichunchen created this gist Apr 19, 2019.
    24 changes: 24 additions & 0 deletions override_wrong.cpp
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #include <iostream>
    using namespace std;

    class Base {
    public:

    // user wants to override this in
    // the derived class
    virtual void func()
    {
    cout << "I am in base" << endl;
    }
    };

    class derived : public Base {
    public:

    // did a silly mistake by putting
    // an argument "int a"
    void func(int a) override
    {
    cout << "I am in derived class" << endl;
    }
    };