C++_Programming_Unit-4[1]
C++_Programming_Unit-4[1]
HANDLING MODEL
3
EXAMPLE-1
5
int main( )
{
#include<iostream> int num;
try
MULTIPLE EXCEPTION
9
Syntax:
try
{
statement(s);
}
RETHROWING EXCEPTION
11
void Function( )
The statement throw is used to rethrow an exception. {
try
It allows an exception without any argument. {
if(condition) throw value;
#include<iostream>
Continue…
13
int main( )
{
int num; 1st RUN
try
The user-defined exception can be created with the help of a class type.
Syntax:
};
try
{
if(Condition(s)) throw Class_Name( );
}
catch(Class_Name Object_Name)
{
// Statement(s);
}
DR. BAPUJI RAO, Department of CSE(CORE)
EXAMPLE
15
FUNCTION TEMPLATE
17
Syntax:
template <class/typename template_name-1, template_name-2, ………...>
return_type Function_Name(template_name-1 variable1,…….)
{
// Statement(s);
}
#include<iostream.h>
template<class T> // template<typename T>
void Show(T a)
EXAMPLE-2
19
#include<iostream.h>
template<class T>
// 1st argument is primitive and the 2nd argument is a
#include<iostream.h>
template <typename A, typename B>
void Show(A a, B b)
EXAMPLE-4
21
Sum of Array of Integers and Array of Floating numbers using Function Template.
#include<iostream.h>
template<class T>
int main( )
{
int a[4] = {1, 4, 3, 7}, res1;
CLASS TEMPLATE
23
public:
// Member Function Template Definition
return_type function_name(template_name var-1, template_name var-2)
{
// Statement(s);
}
};
DR. BAPUJI RAO, Department of CSE(CORE)
TEMPLATE CLASS
25
EXAMPLE-2
Sum and product of two numbers using class template. 27
OUTPUT
template <class T> void main( )
Enter two Integers : 7 6
class SP {
Enter two Floats : 1.4 3.7
{ Integers:
SP<int> obj1;
T a, b; a =7 b=6 SP<float> obj2;
#include<iostream.h> OUTPUT
template<class T> void main( ) 67
class SRM { 67
A function template can also be overloaded by defining more than one with same name
and different signature.
#include<iostream.h>
It is mainly used to represent the organization and the structure of a system in the form
of PACKAGES.
A SET OF CLASSES are grouped into PACKAGES and packages may reside in other
PACKAGE DIAGRAMS
31
Package
• It is a container for organizing different diagram elements such as classes,
interfaces, etc.
Namespace
• It represents the name of the package.
• It generally appears on top of the package symbol.
• Example:
Student
Package Merge
• It is a relationship that signifies how a package can be merged or combined.
•
Package-1 Package-2
<<Merge>>
PACKAGE DIAGRAMS
33
Package Import
• It indicates that functionality has been imported from one package to another.
• It is represented as a dashed arrow and named as <<import>> is written over the line.
3DShape
<<Import>>
<<Import>> <<Import>>
<<Import>> <<Import>>
Shapes
util.Vector Inventory
<<Import>> <<Import>>
Constraint
• It is like a condition or requirement set related to a package.
• It is represented by curly braces.
DR. BAPUJI RAO, Department of CSE(CORE)
PACKAGE DIAGRAMS
35
Date
Account Ordering Shipping
<<Access>>
<<Access>>
Order Processing
<<Import>>
Presentation Layer 37
Application Views
Java AWT
Application Logic
<<Merge>> <<Merge>>
COMPONENT DIAGRAMS
39
DATABASE BOOK
<<depends>>
Transaction
SYSTEM <<depends>> LIBRARY
SEARCH MEMBER
<<depends>>
FEES
DR. BAPUJI RAO, Department of CSE(CORE)
Account
Information
ATM
Transaction
ATM <<Depends>> BANK EMPLOYEE
Machine Database Station
CARD <<Depends>>
CUSTOMER CLIENT
Station READER DESKTOP
Web
Merchant <<Depends>>
Transaction CLIENT
DESKTOP
Transaction
WEB PAGE ONLINE
Transaction
DEPLOYMENT DIAGRAM
45
The Physical files are deployed onto nodes. So that the actual
ARTIFACTS implementation of software components, such as executables,
scripts, databases, etc will be taken place.
DR. BAPUJI RAO, Department of CSE(CORE)
DEPLOYMENT DIAGRAM
46
Payment
DR. BAPUJI RAO, Department of CSE(CORE)
MOBILE BANKING ANDROID SERVICES
48
Application Data
Account
Statement Account
Preparation Details
Client Fund
Web Transfer
Android
Services
Device
Cheque
Transfer Customer
Details
Other
Services