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

  1. //: C04:Sizeof.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. // Sizes of structs
  7. #include "CLib.h"
  8. #include "CppLib.h"
  9. #include <iostream>
  10. using namespace std;
  11.  
  12. struct A {
  13.   int i[100];
  14. };
  15.  
  16. struct B {
  17.   void f();
  18. };
  19.  
  20. void B::f() {}
  21.  
  22. int main() {
  23.   cout << "sizeof struct A = " << sizeof(A)
  24.     << " bytes" << endl;
  25.   cout << "sizeof struct B = " << sizeof(B)
  26.     << " bytes" << endl;
  27.   cout << "sizeof CStash in C = " 
  28.     << sizeof(CStash) << " bytes" << endl;
  29.   cout << "sizeof Stash in C++ = " 
  30.     << sizeof(Stash) << " bytes" << endl;
  31. } ///:~
  32.