Mapping Class Diagram to C++ coding

Discussion in 'C++' started by Jennifer Jazz, May 2, 2007.

  1. My question is regarding the mapping of Class diagram to the C++
    coding.

    There are 3 realtions in Class diagram

    1) Assosication
    2) Composition
    3) Aggregation (Weak Composition).

    -----------------------------------------------------
    Class diagram for A ----- B (Association)
    I handle it coding like that

    main() {
    A objA;
    B objB;

    objA.funA(objB); // or
    objB.funB(objA);
    }

    -----------------------------------------------------
    A <>---- B (filled diamond) for compoistion
    Take the example of CAR and ENGINE, this relation is composition

    I handle it coding like that

    class B {
    }
    class A {
    B objB; //or B* objB
    }

    This shows when A's Object destroys B also destroys.
    Im clear with above two concepts but when aggregation comes.

    A <>---- B (non-filled diamond) for agregation
    Take the example of CAR and WHEEL-CUP.

    class B {
    }
    class A {
    B* ptrB;
    }



    Take the example of CAR and WHEEL-CUP, this relation is aggregation.
    CAR

    changes its wheel-cup each time when it go to service the car.

    CAR <>------ Wheel-CUp

    im not getting one thing thing when car destroyed (i.e. destructor
    called)

    does Wheel-Cup should also destroy? iF yes then the difference
    between

    COMPOSITION and AGGREGATION is only left that in aggregation the
    aggregated

    object (B* ptrB) points to different objects i.e. different wheel cups
    at

    different states. and in COMPOSITION it only keep points to only one
    object.

    AND in both aggre. and comp. object B destoys as object A destroys.

    One more question , in composition the Object B is created as object A
    is

    created i.e. (When CAR is created ENGINE also created) but what abt
    wheel

    cups? when they will be created and destroyed? as wheel cups can
    live

    independly and when car goes for services, they new wheel cups only
    points of

    the this car showing new wheel cups attached. So the other wheel cups

    destroyed !!??

    I shall be very very thankful if u answer me this question
    Jennifer Jazz, May 2, 2007
    #1
    1. Advertising

  2. Jennifer Jazz

    mlimber Guest

    On May 2, 1:12 pm, Jennifer Jazz <> wrote:
    > My question is regarding the mapping of Class diagram to the C++
    > coding. [snip]


    See your other posting of this question for my answer.

    Cheers! --M
    mlimber, May 2, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Piero Massari

    tool to make a class diagram from csharp

    Piero Massari, Jun 15, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    517
    Sahil Malik
    Jun 17, 2004
  2. A.M

    Class Diagram

    A.M, Jan 19, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    831
  3. Bob

    Class diagram

    Bob, Aug 5, 2003, in forum: Java
    Replies:
    2
    Views:
    670
    Andreas Rueckert
    Aug 5, 2003
  4. Brzezi

    UML class diagram generator

    Brzezi, Nov 21, 2004, in forum: Java
    Replies:
    6
    Views:
    37,880
    Joe Kulig
    Nov 24, 2004
  5. calmar
    Replies:
    11
    Views:
    787
    calmar
    Feb 21, 2006
Loading...

Share This Page