home *** CD-ROM | disk | FTP | other *** search
/ Media Share 9 / MEDIASHARE_09.ISO / cprog / blx21.zip / BC31.ARJ / VS.CPP < prev   
Text File  |  1992-04-22  |  294b  |  30 lines

  1. struct    BASE
  2. {
  3.     int    x;
  4. virtual    int    f();
  5.     BASE(int c) : x(c) {};
  6. };
  7.  
  8. int    BASE::f()
  9. {
  10.     return    x;
  11. }
  12.  
  13. struct    DERV:BASE
  14. {
  15.     DERV(int c) : BASE(c) {};
  16. };
  17.  
  18. DERV    d(1), *p = &d;
  19.  
  20. int    main()
  21. {
  22.     int    count = 0;
  23.  
  24.     for    (long i = 1000000; i; --i)
  25.         count += p->f();
  26.  
  27.     return    0;
  28. }
  29. 
  30.