// File: priv5.cpp // // Made all data members private. // #include using namespace std; class foo { public: foo() { // inline member function priv_data1 = 2 ; priv_data2 = 9 ; } void dump() { cout << "priv_data1 = " << priv_data1 << ", priv_data2 = " << priv_data2 << endl ; } private: int priv_data1, priv_data2 ; } ; int main() { foo obj ; int *ptr ; obj.dump() ; // ptr = (int *) &obj ; // Old type cast syntax ptr = reinterpret_cast(&obj) ; // change type to int pointer *ptr = 45 ; obj.dump() ; ptr++ ; *ptr = 58 ; obj.dump() ; }