int main(int argc, char **argv) { Count counter; Count *counterPtr = &counter; Count &counterRef = counter; counter.setX(1); counter.print(); counterPtr->setX(2); counterPtr->print(); counterRef.setX(3); counterRef.print(); counter.print(); }
int main(int argc, const char * argv[]) { Count counter; Count *counterPtr=&counter; Count &counterRef = counter; cout<<"Set counter to 1..\n"; counter.setX(1); counter.print(); cout<<"Set counter Ref to 2..\n"; counterRef.setX(2); counter.print(); cout<<"Set counter Ptr to 3..\n"; counterPtr->setX(3); counterPtr->print(); return 0; }