home *** CD-ROM | disk | FTP | other *** search
/ Reverse Code Engineering RCE CD +sandman 2000 / ReverseCodeEngineeringRceCdsandman2000.iso / RCE / Ebooks / Thinking in C++ V2 / C06 / Multiarg.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-05-25  |  624 b   |  32 lines

  1. //: C06:Multiarg.cpp
  2. // From Thinking in C++, 2nd Edition
  3. // Available at http://www.BruceEckel.com
  4. // (c) Bruce Eckel 1999
  5. // Copyright notice in Copyright.txt
  6. // Multiple constructor arguments
  7. // with aggregate initialization
  8. #include <iostream>
  9. using namespace std;
  10.  
  11. class Z {
  12.   int i, j;
  13. public:
  14.   Z(int ii, int jj);
  15.   void print();
  16. };
  17.  
  18. Z::Z(int ii, int jj) {
  19.   i = ii;
  20.   j = jj;
  21. }
  22.  
  23. void Z::print() {
  24.   cout << "i = " << i << ", j = " << j << endl;
  25. }
  26.  
  27. int main() {
  28.   Z zz[] = { Z(1,2), Z(3,4), Z(5,6), Z(7,8) };
  29.   for(int i = 0; i < sizeof zz / sizeof *zz; i++)
  30.     zz[i].print();
  31. } ///:~
  32.