summaryrefslogtreecommitdiff
path: root/C/OOP/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'C/OOP/main.c')
-rw-r--r--C/OOP/main.c30
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;
+}
+