Last active
December 20, 2015 15:09
-
-
Save mdg/6152423 to your computer and use it in GitHub Desktop.
OO Type Hierarchy
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
class Animal | |
{ | |
public: | |
std::string name; | |
virtual ~Animal() {} | |
}; | |
class Dog : public Animal | |
{ | |
public: | |
DogSymptoms symptoms; | |
}; | |
class Cat : public Animal | |
{ | |
public: | |
CatSymptoms symptoms; | |
}; |
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
data Dog = Dog { name :: String, symptoms :: DogSymptoms } | |
data Cat = Cat { name :: String, symptoms :: CatSymptoms } |
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
class Veterinarian | |
{ | |
private: | |
DoctorOfVeterinaryMedicineDegree degree; | |
}; |
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
data Veterinarian = Vet { degree :: DoctorOfVeterinaryMedicineDegree } | |
class TreatableAnimal a where | |
treat :: Veterinarian -> a -> a | |
instance TreatableAnimal Dog where | |
treat vet dog = blah blah | |
instance TreatableAnimal Cat where | |
treat vet cat = blah blah |
kyledseever
commented
Aug 5, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment