#include <iostream> #include <stdlib.h> using namespace std; class Foo { public: int i; float f; char *cp; }; int main() { Foo f1; if(f1.cp == 0) cout <<" in stack,f1.cp is null "<< endl; cout<< f1.i << " " << f1.f <<" "<<f1.cp << endl; Foo *pf = new Foo(); if(pf->cp == 0) cout <<" in heap,pf.cp is null "<< endl; cout << pf->i << " " << pf->f << " "<< pf->cp <<endl; return 0; }
/work/ctest/insideTheC++ObjectModel$ ./1
770374040 4.55997e-41 H�l$�L�d$�H�-
in heap,pf.cp is null
0 0