Skip to content

Instantly share code, notes, and snippets.

@dionyziz
Created April 15, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dionyziz/4283883d1ea68291d6f825923f8d9553 to your computer and use it in GitHub Desktop.
Save dionyziz/4283883d1ea68291d6f825923f8d9553 to your computer and use it in GitHub Desktop.
#include <cstdio>
#include <iostream>
using namespace std;
class A {
public:
virtual int a() {
return 5;
}
};
class B: public A {
public:
virtual int b() {
return 17;
}
};
void mymethod(A* a) {
cout << a->a() << endl;
}
int main() {
B* b = new B();
mymethod(b);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment