Last active
August 29, 2015 14:05
-
-
Save oprypin/222ab964824f3541f72a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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