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

  1. //: C09:Inline.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. // Inlines inside classes
  7. #include <iostream>
  8. using namespace std;
  9.  
  10. class Point {
  11.   int i, j, k;
  12. public:
  13.   Point() { i = j = k = 0; }
  14.   Point(int ii, int jj, int kk) {
  15.     i = ii;
  16.     j = jj;
  17.     k = kk;
  18.   }
  19.   void print(const char* msg = "") const {
  20.     if(*msg) cout << msg << endl;
  21.     cout << "i = " << i << ", "
  22.          << "j = " << j << ", "
  23.          << "k = " << k << endl;
  24.   }
  25. };
  26.  
  27. int main() {
  28.   Point p, q(1,2,3);
  29.   p.print("value of p");
  30.   q.print("value of q");
  31. } ///:~
  32.