Professional Documents
Culture Documents
HOME ABOUT
As you know a Class diagram is a diagram showing di"erent classes in a system their
attribute, operation and the relationship among di"erent objects.
TOTAL VISITORS
418,368 hits
ARCHIVES
October 2020
September 2020
August 2020
August 2019
July 2019
February 2019
Even I have been using it for long time; I always had confusion each time when I use December 2018
it. This post is meant for such people; also it will be helpful for beginners, here I will August 2018
explain the class diagram with C++ class example.
July 2018
May 2017
April 2017
June 2016
May 2016
Class diagram for the above class is shown below.
April 2016
March 2016
February 2016
December 2015
November 2015
October 2015
September 2015
Di!erent visibility of the class can be represented as
August 2015
“+” Public
July 2015
“-” Private
“#” Protected June 2015
May 2015
Di!erent Parameter direction
April 2015
“in” The parameter is an input parameter.
March 2015
“Inout” The parameter is capable of both input and output.
“Out” The parameter is an output parameter. February 2015
January 2015
Di!erent type of members in a class
December 2014
1) Static members are represented as underlined.
November 2014
2) Pure virtual functions are represented as italics.
October 2014
Class relationship September 2014
August 2014
In a system a class may be related to di"erent classes,following are the di"erent
relation ship. July 2014
June 2014
Association (knows a)
May 2014
Dependency (uses a)
March 2014
Composition (has a)
Aggregation (has a) February 2014
Advertisements
CATOGORIES
REPORT THIS AD
Design Pattern
Java
Modern C++
NetWorking
Class X {
POSIX
Recommendation
void SetY(Y *y) { y_ptr = y; }
STL
Uncategorized
void f() { y_ptr->Foo();}
---- VC++/MFC
DISCLAIMER
Dependency
One class depends on another if the independent class is a parameter variable or “The information in this weblog
local variable of a method of the dependent class is provided “AS IS” with no
warranties, and confers no
Representaion
rights.”
M T W T F S S
class X {
1
...
void f1(Y y) {…; y.Foo(); } 2 3 4 5 6 7 8
Jan »
Aggregation
Aggregation can occur when a class is a collection or container of other classes, but
where the contained classes do not have a strong life cycle dependency on the
container—essentially, if the container is destroyed, its contents are not. You may SUBSCRIBE TO BLOG VIA
have confusion between aggregation and association .Association di"ers from EMAIL
aggregation only in that it does not imply any containment.
Enter your email address to
Representaion
subscribe to this blog and
receive noti#cations of new
posts by email.
Email Address
C++ Example
Subscribe
Example 1
Example 2:
A car has it’s tiers, and the scope of tyre doesn’t depend on a car since a tyre can be
used for another car also LAST MONTH VIEW
A Rectangle class has its style, which may be shared by other shapes also; life time of TOP POSTS & PAGES
style doesn’t depend on Rectangle class.
UML Class Diagram Explained
With C++ samples
QT interview questions
Composition is the stronger form of aggregation. Composition can occur when a of the calling function in C++
class is a collection or container of other classes, but where the contained classes UDP socket class in C++
have a strong life cycle dependency on the container—essentially, if the container is Thread Pool class using modern
destroyed, its contents are also destroyed c++
Representation
Plug In Architecture In C++
class Circle
Advertisements
{
private:
...
Point center;
....
};
class X { Generate
reliable data
...
Ensure 100 %
Y a; // 1; Composition accuracy in time
Y b[10]; // 0..10; Composition and efficiency
}; Wallet HR
class X {
X() { a = new Y[10]; }
~X(){ delete [] a; }
...
Y *a; // 0..10; Composition
};
...
vector a;
};
Inheritance (Generalization)
In Inheritance relationship a class is derived from another class. It is a “is a”
relationship between two classes.
Representation
class_diagram_inheritance_2
Here Shape is an abstract class that is why it is shown in Italics. Draw () and Erase ()
methods of Shape class is pure virtual function, so it is also shown as italics.
Class Template
Template class mean generic classes.Languages like C++, java, C# supports generic
programming.
Representation
C++ represenatation
template
class X {
...
...
...
};
X Y
...
X a;
...
Share this:
Loading...
Related
xs4rahulgoel
Reply
Parthasarathy
Reply
Shalin
Very useful information specially for the 2nd year assignments OOP. I
found more in the UML diagram tutorial
Reply
Willem
Class X {
Am I wrong here?
Greetings Willem
Reply
Sadique Ali E
Reply
Manuel Malagon
So:
Is this correct?
Sadique Ali E
Josh
Yes! Finally a decent post about UML C++ diagrams that is straight to the
point!
Reply
Sadique Ali E
Reply
Josh
Reply
Clayton Huntsman
Reply
Sadique Ali E
Thanks
Reply
Ken
This article is very helpful! I wish, though that objects used had more
visual examples to help visualizing the objects.
Class X {
X(Y *y) : y_ptr(y) {}
Why not …
Class Car { Car(Wheel * wheel): wheel_ptr(wheel)()
Reply
Tony
I think there is a mistake in the very #rst class diagram. The connection
drawn between the Vehicle class and the Wheel class is wrong. You have
the white diamond drawn at the Wheel class, when it should be drawn at
the Vehicle class. The Vehicle aggregates the Wheel, not the other way
around.
Cheers,
Tony
Reply
Sadique Ali E
Reply
Adrian
Nice article
Reply
Adrian
Reply
Sadique Ali E
Sadique Ali E
Thanks
Reply
Carlos Maceira
Reply
m4l490n
How would you model a map? for example, you have two classes, A and B.
Class B has a map of
class A {
};
class B {
private:
std::map classBs;
};
Reply
sadasivam
Hi, I am new to uml modelling language. Somehow, I will grab the basics
and excel in it. I want to know which UML books can be useful in terms of
begineer. I need the guide for, cpp code generation for every concepts. I
referred lot of UML reference guide. In every guide, the #nal code
generation is sonewhat missing. So, for a begineer it is unable to grab
what will be the exact output generated. If this helps, then I can able to
learn by working with it. Can you guide me in this?
Reply
sadash
Hi, is there any uml reference book with sample codes for every
concepts? As a begineer, its to work with it but, dont know how to
approach this.
Reply
sadash
Reply
Arkan
Reply
Arkan
Reply
Ilya
class Window
{
public:
//…
private:
vector itsShapes;
};
Reply
adityamall90
I was almost hopeful that someone would give examples with classes not
being circle or rectangle or some geometric shape for god’s sake, but
today is not that day.
Reply
Leave a Reply
Advertisements
REPORT THIS AD