| Bruce Eckel's Thinking in C++, 2nd Ed | Contents | Prev | Next |
//: C04:Sizeof.cpp
// Sizes of structs
#include <cstdio>
#include "Lib.h"
#include "Libcpp.h"
using namespace std;
struct A {
int i[100];
};
struct B {
void f();
};
void B::f() {}
int main() {
printf("sizeof struct A = %d bytes\n",
sizeof(A));
printf("sizeof struct B = %d bytes\n",
sizeof(B));
printf("sizeof CStash in C = %d bytes\n",
sizeof(CStash));
printf("sizeof Stash in C++ = %d bytes\n",
sizeof(Stash));
} ///:~