-
-
Save nddrylliog/287811 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
The bird is eating worms | |
The animal is eating stuff |
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
The bird is eating worms | |
The animal is eating worms |
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
Animal: class { | |
eat: final func -> String { return "eating stuff" } | |
} | |
Bird: class extends Animal { | |
eat: final func -> String { return "eating worms" } | |
} | |
main: func () { | |
bird := Bird new() | |
animal := bird as Animal | |
"The bird is %s" format(bird eat()) println() | |
"The animal is %s" format(animal eat()) println() | |
} |
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
Animal: class { | |
eat: func -> String { return "eating stuff" } | |
} | |
Bird: class extends Animal { | |
eat: func -> String { return "eating worms" } | |
} | |
main: func () { | |
bird := Bird new() | |
animal := bird as Animal | |
"The bird is %s" format(bird eat()) println() | |
"The animal is %s" format(animal eat()) println() | |
} |
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; | |
class Animal | |
{ | |
public: | |
void Eat() | |
{ | |
cout << "eating stuff" << endl; | |
} | |
}; | |
class Bird : public Animal | |
{ | |
public: | |
void Eat() | |
{ | |
cout << "eating worms" << endl; | |
} | |
}; | |
int main() | |
{ | |
Bird* b = new Bird; | |
Animal* a = (Animal*)b; | |
cout << "The bird is "; | |
b->Eat(); | |
cout << "The animal is "; | |
a->Eat(); | |
return 0; | |
} |
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
The bird is eating worms | |
The animal is eating stuff |
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
The bird is eating worms | |
The animal is eating worms |
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; | |
class Animal | |
{ | |
public: | |
virtual void Eat() | |
{ | |
cout << "eating stuff" << endl; | |
} | |
}; | |
class Bird : public Animal | |
{ | |
public: | |
virtual void Eat() | |
{ | |
cout << "eating worms" << endl; | |
} | |
}; | |
int main() | |
{ | |
Bird* b = new Bird; | |
Animal* a = (Animal*)b; | |
cout << "The bird is "; | |
b->Eat(); | |
cout << "The animal is "; | |
a->Eat(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment