Data and the functions that operate on that data are combined into an object.
Programming is not function based but object based.
Objects are base on three basic ideas: Encapsulation, Inheritance and Polymorphism.
Re-use of code. Linking of code to objects and explicit specification of relations between objects allows related objects to share code.
redesign and extension facilitated by encapsulation, data abstraction which allow for very clean designs.
other improvements - some resulting in deprecation of some C facilities. New facilities are supplied for I/O, memory allocation and error handling; macros and pointer casts become obsolete for the most part.
What are the member access operators? Describe the usage by giving example.
Dot operator (.) for structure and class members
Arrow operator () for structure and class members via pointer to object
Print member hour of timeObject:
cout << timeObject.hour;
OR
timePtr = &timeObject;
cout << timePtr->hour;}
timePtrhour same as ( *timePtr ).hour
Describe C-style struct structure and compare with C++ style class structure.
C-style structures
No interface; If implementation changes, all programs using that struct must change accordingly
Cannot print as unit; Must print/format member by member
Cannot compare in entirety; Must compare member by member
Classes
Model objects; Attributes (data members), Behaviors (member functions), Encapsulation