diff options
| author | Carlos Maiolino <[email protected]> | 2025-07-10 22:55:07 +0200 |
|---|---|---|
| committer | Carlos Maiolino <[email protected]> | 2025-07-10 22:56:55 +0200 |
| commit | d98f46ce647846b0aa30b2e16a30fd4e152a1bf5 (patch) | |
| tree | 267474fcc77cf20b428f6f4c7f768ca09f4cfe0e /C/OOP/main.c | |
| parent | 869e68986aa8f69af6e7842260a68d1e5c6f796f (diff) | |
Add new code
Signed-off-by: Carlos Maiolino <[email protected]>
Diffstat (limited to 'C/OOP/main.c')
| -rw-r--r-- | C/OOP/main.c | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/C/OOP/main.c b/C/OOP/main.c new file mode 100644 index 0000000..7943580 --- /dev/null +++ b/C/OOP/main.c @@ -0,0 +1,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; +} + |
