#include <iostream> using namespace std; class Distance { private: int feet; float inches; public: void getdist() { cout << "\nEnter feet: "; cin >> feet; cout << "Enter inches: "; cin >> inches; } void showdist(){ cout << feet << "\'-" << inches << '\"'; } }; int main(){ Distance& dist = *(new Distance); dist.getdist(); dist.showdist(); cout << endl; return 0; }
11.7.object pointer | ||||
11.7.1. | Pointers to Objects | |||
11.7.2. | uses a pointer to access all three elements of array ob after being assigned ob's starting address | |||
11.7.3. | assign the address of a public member of an object to a pointer and then access that member by using the pointer | |||
11.7.4. | dereferencing the pointer returned by new | |||
11.7.5. | array of pointers to objects |