SHARE
TWEET

human.h

a guest May 20th, 2012 22 Never
  1. /*-
  2.  * Copyright (c) 2012 valsorym <valsorym.e@gmail.com>.
  3.  * All rights reserved.
  4.  *
  5.  * Discussion on the forums.freebsd.org.
  6.  *  url: http://forums.freebsd.org/showthread.php?p=177208
  7.  */
  8.  
  9. /*
  10.  * Very simple class, for example OOD in ANSI C.
  11.  */
  12.  
  13. /* NEW TYPES */
  14. /* ************************************************************************* */
  15.  
  16. #ifndef HUMAN_H
  17. #define HUMAN_H
  18.  
  19. #include <stdio.h>
  20. #include <stdlib.h>
  21. #include <string.h>
  22.  
  23. /* –°lass of persons. */
  24. struct w_human {
  25.     /* Private: */
  26.     int age;
  27.     char *name;
  28.  
  29.     /* Public: */
  30.     int (*setage)(struct w_human *, int );
  31.     int (*getage)(struct w_human *);
  32.    
  33.     char *(*setname)(struct w_human *, char *);
  34.     char *(*getname)(struct w_human *);
  35. };
  36.  
  37. /* Class initializer. */
  38. extern const struct w_human_initializer {
  39.     struct w_human *(*create)(int , char *);
  40.     void (*destroy)(struct w_human *);
  41. } w_human;
  42.  
  43. #endif
  44.  
  45. /* The End. */
RAW Paste Data
Top