daily pastebin goal
12%
SHARE
TWEET

Untitled

a guest May 17th, 2018 112 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. class DBObject {
  2. private:
  3.     . . . // state
  4. public:
  5.     void saveState() { . .. }
  6.     void loadState() { . .. }
  7.     . . .
  8. }
  9.  
  10. class StorableShape : Shape {
  11.     private DBObj ect _store;
  12.     alias _store this;
  13.     this( ) {
  14.         _store = new DBObj ect;
  15.     }
  16.     . . .
  17. }
  18.  
  19. unittest {
  20.     auto s = new StorableShape;
  21.     s. draw( ) ;        // call a Shape method
  22.     s. saveState() ;    // call a DBObject method
  23.                 // gets rewritten as s._store.saveState()
  24.     Shape sh = s;       // normal upcast derived -> base
  25.     DBObj ect db = s;   // rewritten as DBObject db = s._store
  26. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top