#include <stdio.h> #include <stdlib.h> #include <string.h>struct Dog /* declare structures*/ { char name [256]; }; struct Cat { char name [256]; }; /* declare overloaded function*/ void speak(Dog dog) { printf ("%s says woof\n", dog.name); } void speak (Cat cat) { printf ("%s says meow\n", cat.name); } int main() /* main function*/ { Dog dog; /*struct vars*/ Cat cat; /*assign names to Dog and Cat*/ strcpy (dog.name,"Spot"); strcpy (cat.name,"Tiger"); /*call of overloaded function*/ speak (dog); speak (cat); /*system delay*/ system ("pause"); return 0; }
Comments