Created
October 25, 2014 11:02
-
-
Save ixn/5d4f2a37dea78b45db69 to your computer and use it in GitHub Desktop.
Simple object oriented in C (http://deeprhezy.tumblr.com)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #ifndef __OBJECT_H__ | |
| #define __OBJECT_H__ | |
| #include <stdio.h> | |
| #include <stdlib.h> | |
| #include <string.h> | |
| /* membuat pengelompokan data dengan struct | |
| kita beri nama object yang berisi (object1 & object2) | |
| */ | |
| struct object | |
| { | |
| char* object1; | |
| char* object2; | |
| }; | |
| /* struct object di inisialkan dengan nama yang sama yaitu "object" | |
| jadi saat pendeklarasian menggunakan/mengikutkan struct object, | |
| tinggal menggunakan object* | |
| */ | |
| typedef struct object object; | |
| /* Deklarasi object */ | |
| /* object_new dibuat untuk mengalokasinya memory pada struct object. | |
| harus melakukan object_free() saat menggunakan fungsi ini | |
| */ | |
| object* | |
| object_new(void); | |
| /* object_free untuk menghapus memory yang dialokasikan oleh object_new() */ | |
| void | |
| object_free(object* obj); | |
| /* fungsi ini untuk melakukan display/printf data. | |
| data yang masuk bersumber dari program utama (main) | |
| */ | |
| void | |
| object_display(object* obj); | |
| #endif //__OBJECT_H__ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment