473,548 Members | 2,604 Online
Bytes | Software Development & Data Engineering Community
+ 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 1365
On May 2, 2:23 pm, Jennifer Jazz <Jeniffer...@gm ail.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
5526
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. Is it possible to do the same but with a URL?
20
3272
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 ' 2' Now, with a mapping....
6
6517
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 #define CHANNEL_1 1 #define CHANNEL_2 2
10
2033
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
2673
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. Similar to the solution of Dave Kuhlman (http://www.rexx.com/~dkuhlman/generateDS.html) where the mapping is defined in an xml file (if I am understand...
3
1607
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 those"--"those" representing, among others, O/R mapping). Probably I'm missing something really obvious, but a google search only gave me...
4
3073
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 use. The equivalent GUI steps would be, open IIS, select my application->properties, app configuration, in whildcard application mapping type the...
1
1708
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: :::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: Invalid column name 'Unique_ref'. Invalid column name 'ID_string'. Invalid column...
1
2555
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 emps - 1 for manager and the second for workers (Collection). How can I map this? We can add additional fields in the emp table that indicates the...
6
3082
by: Jan Kucera | last post by:
Hi, does anybody know about wildcard mapping ASP.NET 2 in IIS6? Any tutorial? Thanks, Jan
0
7512
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7707
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7951
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
7803
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6036
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5362
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
1926
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 we have to send another system
0
751
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.