Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 12. Composite Classes: Pitfalls ... > Using Class Objects as Data Members

Using Class Objects as Data Members

As was explained in Chapter 9, "C++ Class as a Unit of Modularization," the main purpose of the class construct in C++ is to let the programmer bind together those data and operations that logically belong together in the eyes of the class designer.

Almost all examples of C++ classes that appeared earlier in the book had data members of built-in types—integers, and floating point numbers. Some more complex examples had a character array as a data member. Actually, it was a pointer to a character array allocated on the heap. From the point of view of class composition, a pointer is similar to integers and floating point numbers. It has no internal structure of its own that is accessible from the outside.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free 10-Day Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint