Sams Teach Yourself C in 21 Days

(singke) #1
Working with C++ Classes and Objects 699

BD3


reuse, they are all typically used in real world C++ programs. It is beyond the scope of
this book to cover all these here. However, with what has been covered here, you are
primed to start using C++.

Where to Go to Learn More ..........................................................................

You have learned the foundation of C++. To learn more, you should consider looking at a
book that covers all the features of C++. This could include anotherSams Teach Yourself
book such as Sams Teach Yourself C++ in 21 Days by Jesse Liberty, or a more advanced
book such as C++ Unleashed.

Summary ............................................................................................................


Today you covered the core concepts that make C++ an object-oriented language. You
learned about classes and the objects that can be instantiated with them. You learned
about data members and member functions. Additionally, you learned how to create and
use constructors and destructors.
A lot of material was covered today; however, if you move deeper into C++, understand-
ing today’s material will be crucial. The object is the center of object-oriented program-
ming. Today you learned how to encapsulate information into an object. You also saw
how to make an object more polymorphic by using function overloading.
As today’s lesson progressed, you reviewed the object-oriented constructs implemented
in C++. You then saw how classes can be used as data members within other classes.
After a quick listing, you jumped into single inheritance, where you saw how to use base
classes and subclasses. In learning about inheritance, you also learned about the order in
which constructors and destructors are executed in derived classes. Finally, today’s
lessons ended by providing a caution that you have just begun the journey into C++.
In tomorrow’s lesson, you get to change focus, although only slightly. Starting tomorrow,
you move into a primer on another object-oriented language, Java.

Q&A ....................................................................................................................


Q If a structure can do everything a class can, why not use classes for every-
thing—or use structures for everything?
AGenerally a structure is used if you are using only data member values. If you are
including member functions, it is recommended that you use a class instead of a
structure.

38 448201x-Bonus3 8/13/02 11:19 AM Page 699

Free download pdf