home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_07_06 / v7n6034a.txt < prev    next >
Text File  |  1989-07-25  |  512b  |  20 lines

  1. // CI.CXX: An example of the copy-initializer
  2. // being used for initialization.
  3.  
  4. class ci {
  5.   int i;
  6. public:
  7.   ci(int j) { i = j; }
  8.   // copy-initializer:
  9.   ci(ci & rv) { 
  10.     puts("copy-initializer called");
  11.     i = rv.i; // copy in the rvalue
  12.   }
  13. };
  14.  
  15. main() {
  16.   ci original(1);
  17.   ci copy1(original); // copy-initializer called.
  18.   ci copy2 = original; // here, too
  19. }
  20.