Skip to content

Instantly share code, notes, and snippets.

@oprypin
Last active August 29, 2015 14:05
Show Gist options
  • Save oprypin/222ab964824f3541f72a to your computer and use it in GitHub Desktop.
Save oprypin/222ab964824f3541f72a to your computer and use it in GitHub Desktop.
#include <iostream>
using namespace std;
struct Base {
void f() {
cout << "base" << endl;
}
void g() {
f();
}
};
struct Child: public Base {
void f() {
cout << "child" << endl;
}
};
int main() {
Child x;
x.g();
return 0;
}
//output: base
type
TBase = object of TObject
TChild = object of TBase
proc f(self: var TBase) =
echo "base"
proc g(self: var TBase) =
self.f()
proc f(self: var TChild) =
echo "child"
var x: TChild
x.g()
#output: base
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment