blob: 794358028ef498d15e1f503417b273e599863f95 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/*
* Simple program exemplifying the usage of Animal class
* and its sub-classes
*/
#include <stdio.h>
/*
* The main program here, only need access to the public interfaces
* but the sub-classes will need access to the animal's private interface
*/
#include "animal_p.h"
#include "cat_p.h"
int main(void) {
/* We don't need to know how the cat object is implemented */
struct cat *myCat = cat_new();
cat_ctor(myCat);
/*
* For us to have the Animal class definition hidden, the animal_sound()
* should have a way to defer the parent Animal class, from the cat class.
*
* See its implementation within animal.c
*/
animal_sound((struct animal *)myCat);
return 0;
}
|