Thread: Classes with Other Classes as Member Data

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Sep 2005
    Posts
    4

    Classes with Other Classes as Member Data

    Hi,

    I am learning C++ at the moment and I am struggling with the following:

    Classes with Other Classes as Member Data.

    I am wondering if anyone could show me a quick (commented) example of how this works.


    This is from the book I am learning from BTW:

    It is not uncommon to build up a complex class by declaring simpler classes and including them in the declaration of the more complicated class. For example, you might declare a wheel class, a motor class, a transmission class, and so forth, and then combine them into a car class. This declares a has-a relationship. A car has a motor, it has wheels, and it has a transmission.

    I basically could do with a simpler example so I can get my head around it easier than the example given in the book.


    Thanks in advance.
    Last edited by njd; 09-27-2005 at 09:10 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Class with pointers to other classes as member data.
    By Sclorch in forum C++ Programming
    Replies: 2
    Last Post: 02-09-2009, 05:59 AM
  2. Bitmasking Problem
    By mike_g in forum C++ Programming
    Replies: 13
    Last Post: 11-08-2007, 12:24 AM
  3. Replies: 4
    Last Post: 06-14-2005, 05:45 AM
  4. How do I base size of arrays on annother number?
    By Dual-Catfish in forum C++ Programming
    Replies: 15
    Last Post: 09-25-2001, 01:31 PM
  5. Initilize data member
    By xstone in forum C++ Programming
    Replies: 6
    Last Post: 09-24-2001, 05:38 PM