473,480 Members | 3,135 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Mapping

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

May 2 '07 #1
1 1362
On May 2, 2:23 pm, Jennifer Jazz <Jeniffer...@gmail.comwrote:
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
This is more of a UML question (the C++ syntax is only incidental) and
should be asked on comp.object or similar. See this FAQ for what is on-
topic here:

http://www.parashift.com/c++-faq-lit...t.html#faq-5.9

<OT>My recollection is that composition implies that one class owns
the other entirely, whereas aggregation implies that one class holds a
reference to another but isn't its owner. If that is accurate, then a
better analogy would be a car which holds references for each of the
people/pets/whatever that it is carrying. It doesn't own them and they
shouldn't necessarily be destroyed when it is, but the car may need to
access their methods/properties (e.g., to get their weight for vehicle
dynamics or some such).</OT>

Cheers! --M

May 2 '07 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
5519
by: Frank | last post by:
Hi there, In web.xml, I know it's possible to do path mapping: <path-mapping url-pattern="/aaa/*" real-path="C:\TEMP\"/> So a call to myserver.com/mywebapp/aaa will redirect to c:\temp. ...
20
3262
by: Pierre Fortin | last post by:
Hi! "Python Essential Reference" - 2nd Ed, on P. 47 states that a string format can include "*" for a field width (no restrictions noted); yet... >>> "%*d" % (6,2) # works as expected ' ...
6
6500
by: naruto | last post by:
Hi all, I have the following being defined in a A.cxx file. // define in source file. Not exported to the outside world (this cannot be // moved to the header file ) #define CHANNEL_0 0...
10
2025
by: mike | last post by:
regards: Where to find tag mapping-table of HTML translated to XHTML1.0 Any positive suggestion is welcome. thank you May goodness be with you all
1
2661
by: Tamas Hegedus | last post by:
Hi! I am looking for an xml-object mapping tool ('XML Data Binding-design time product') where I can define the mapping rules in 'binding files' and the parser is generated automatically. ...
3
1601
by: Elder Hyde | last post by:
I was reading this interview with Hejlsberg, when suddenly the conversation turned to O/R mapping. Hejlsberg talked as if he had had to design an O/R mapping for .NET (he said ".NET had each one of...
4
3068
by: BentleyInc | last post by:
I'm trying to find a way to add a whildcard application mapping to aspnet_isapi.dll in IIS programmatically.... been looking into IIS administrator reference but didn't find the right function to...
1
1705
by: none | last post by:
Hi, I'm trying to establish table mappings, and I've hit a snag. At the point to where I try to fill the schema (DB_adapter.FillSchema), I get an exception, and the message is as follows:...
1
2548
by: Ram | last post by:
Hey, I'm having a trouble mapping a connecting between 2 of my tables. We have 2 tables - the simplest "dept", "emp" tables which are mapped to 2 classes. Class Dept contains 2 properties for...
6
3071
by: Jan Kucera | last post by:
Hi, does anybody know about wildcard mapping ASP.NET 2 in IIS6? Any tutorial? Thanks, Jan
0
7055
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
6920
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7061
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7110
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
7030
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3015
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3011
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1313
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
210
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.