mirror of
https://github.com/lloeki/cblocks-clobj.git
synced 2025-12-06 10:44:40 +01:00
encapsulate print, method-style
This commit is contained in:
parent
6a6cbef986
commit
cbe43f63fd
1 changed files with 5 additions and 1 deletions
6
main.c
6
main.c
|
|
@ -17,13 +17,17 @@ void Post_init(Post *self) {
|
||||||
*self->body = '\0';
|
*self->body = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Post_printf(Post *self) {
|
||||||
|
printf("%s\n\n%s\n", self->author, self->body);
|
||||||
|
}
|
||||||
|
|
||||||
void Post_dealloc(Post *self) {
|
void Post_dealloc(Post *self) {
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
Post *post = Post_alloc();
|
Post *post = Post_alloc();
|
||||||
printf("%s\n\n%s\n", post->author, post->body);
|
Post_printf(post);
|
||||||
Post_dealloc(post);
|
Post_dealloc(post);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue