Thread: composition relations

  1. #1
    Registered User
    Join Date
    Nov 2011
    Posts
    96

    composition relations

    Hi Guys,

    I want to make a program and in that program I want to make a composition relations.

    Eg. I have a class of "Vehicle" and a class of "Bus".

    Vehicle class has general data members which are inherited by class "Bus".

    But I wanted to know that how can I show composition relations between these 2 classes of "Vehicle" and "Bus"?

    eg.

    Code:
    class Vehicle
    {
    private :
    
    int regno;
    char name;
    
    public:
    get int regno();
    get char name();
    
    };
    
    
    class Bus : public Vehicle
    
    {
    private:
    char buscolor;
    
    public:
    get int regno();
    get char name();
    
    };
    Now how can i show a composition relation between class "Bus" and the "Vehicle"?

    Thanks

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by student111
    But I wanted to know that how can I show composition relations between these 2 classes of "Vehicle" and "Bus"?
    What is "composition"? Does such a relationship make sense between "Vehicle" and "Bus"?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    [](){}(); manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    *nullptr
    Posts
    2,657
    Quote Originally Posted by laserlight View Post
    Does such a relationship make sense between "Vehicle" and "Bus"?
    Of course it does !
    Have an open mind.

  4. #4
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    STUDY A ........ING BOOK!

    I can't believe this crap.

    Why are you trying to pull a working programming knowledge from the ..... of the regulars at this forum?

    You approach is unbelievable stupid. I'm having more trouble wrapping my mind around your level of stupidity than I had with Calculus.

    If you'll just read a book you'll find all the answers to these easily searchable questions.

    Heck, if you just bothered to read the answers from the four forums you shotgun this crap at you would be significantly less stupid.

    [Edit]
    Removed some language the forum software did not.
    [/Edit]

    Soma

    Program of inheritance
    further about Inheritance
    About string and stlib
    Hi some questions
    read from input file
    some questions about structure
    Some problem with my program
    Last edited by phantomotap; 06-19-2012 at 06:28 AM.

  5. #5
    Registered User antred's Avatar
    Join Date
    Apr 2012
    Location
    Germany
    Posts
    257
    That was kind of harsh. =0

  6. #6
    Master Apprentice phantomotap's Avatar
    Join Date
    Jan 2008
    Posts
    5,108
    That was kind of harsh.
    Fair enough in your opinion, but before you hold me to be too harsh read all of his posts.

    Not only is he doing himself a great disservice in the approach, he is wasting a lot of time a lot of people donate by asking the same or extremely similar questions over and over on many different forums occasionally at the same freaking time.

    Someone, I'm not sure who, has been denied the benefit of the time the regulars at these forums contribute because they wasted it on this individual.

    Oh, and I don't even think he is a troll; if I though he was a troll my turn would have been worse but unwritten.

    Soma

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help to do a calcutalor for arithmetic and relations !!!!Pls
    By ryannguyen100 in forum C++ Programming
    Replies: 1
    Last Post: 10-26-2011, 10:43 PM
  2. Composition
    By Fatima Rizwan in forum C++ Programming
    Replies: 4
    Last Post: 10-31-2009, 09:39 AM
  3. Difference Equations / Recurrence Relations
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 10-05-2007, 10:26 AM
  4. Need help with Composition
    By cuddlez.ini in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2004, 08:28 PM
  5. composition, i think
    By blight2c in forum C++ Programming
    Replies: 3
    Last Post: 05-01-2002, 08:49 PM