Created
February 27, 2014 20:39
-
-
Save bitwiser/9259072 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Dog{ | |
string name; | |
}; | |
struct Cat{ | |
string name; | |
}; | |
void speak(Dog d){ | |
cout<<d.name<<" says woof\n"; | |
} | |
void speak(Cat c){ | |
cout<<c.name<<" says meow\n"; | |
} | |
int main(){ | |
/* testing the struct and methods*/ | |
Dog d; | |
d.name="Spot"; | |
Cat c; | |
c.name="Tiger"; | |
speak(d); | |
speak(c); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment