Skip to content

Instantly share code, notes, and snippets.

@bitwiser
Created February 27, 2014 20:39
Show Gist options
  • Save bitwiser/9259072 to your computer and use it in GitHub Desktop.
Save bitwiser/9259072 to your computer and use it in GitHub Desktop.
#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