Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

oodmain.c

By: a guest on May 20th, 2012  |  syntax: C  |  size: 1.24 KB  |  views: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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. #include <stdio.h>
  10.  
  11. #include "employee.h"
  12.  
  13. int
  14. main(int argc, char **argv)
  15. {
  16.     struct w_employee
  17.         *e0 = w_employee.create(32, "Jim K.", "Manager"),
  18.         *e1 = w_employee.create(32, "Sara M.", "Secretary");
  19.  
  20.    
  21.     printf("Worker 1:\n"
  22.         "\tName: %s\n"
  23.         "\tAge: %d\n"
  24.         "\tPost: %s\n",  e0->human->getname(e0->human),
  25.         e0->human->getage(e0->human), e0->getpost(e0));
  26.        
  27.     printf("Worker 2:\n"
  28.         "\tName: %s\n"
  29.         "\tAge: %d\n"
  30.         "\tPost: %s\n", e1->human->getname(e1->human),
  31.         e1->human->getage(e1->human), e1->getpost(e1));
  32.  
  33.     /* Dismiss an old manager, and hire a beautiful brunette. ;) */
  34.     e0->human->setage(e0->human, 21);
  35.     e0->human->setname(e0->human, "Dasha N.");
  36.  
  37.     printf("Worker 1:\n"
  38.         "\tName: %s\n"
  39.         "\tAge: %d\n"
  40.         "\tPost: %s\n",  e0->human->getname(e0->human),
  41.         e0->human->getage(e0->human), e0->getpost(e0));
  42.  
  43.     w_employee.destroy(e0);
  44.     w_employee.destroy(e1);
  45.  
  46.     return 0;
  47. }
  48.  
  49. /* The End. */
clone this paste RAW Paste Data