UNIT I C++ Notes
UNIT I C++ Notes
1
Object-oriented programming paradigm.
Object-Oriented Analysis
Identifying objects
Organizing the objects by creating object model diagram
Defining the internals of the objects, or object attributes
Defining the behavior of the objects, i.e., object actions
Describing how the objects interact
The common models used in OOA are use cases and object models.
Object-Oriented Design
Object–Oriented Design (OOD) involves implementation of the conceptual model
produced during object-oriented analysis. In OOD, concepts in the analysis model,
which are technology−independent, are mapped onto implementing classes, constraints
are identified and interfaces are designed, resulting in a model for the solution domain,
i.e., a detailed description of how the system is to be built on concrete technologies.
The implementation details generally include −
2
Object-Oriented Programming
Object-oriented programming (OOP) is a programming paradigm based upon objects
(having both data and methods) that aims to incorporate the advantages of modularity
and reusability. Objects, which are usually instances of classes, are used to interact with
one another to design applications and computer programs.
The important features of object–oriented programming are −
Types of Models:
There are 3 types of models in the object oriented modeling and design are: Class
Model, State Model, and Interaction Model. These are explained as following
below.
1. Class Model:
The class model shows all the classes present in the system. The class model
shows the attributes and the behavior associated with the objects.
The class diagram is used to show the class model. The class diagram shows the
class name followed by the attributes followed by the functions or the methods
that are associated with the object of the class. Goal in constructing class model
is to capture those concepts from the real world that are important to an
application.
3
2. State Model:
State model describes those aspects of objects concerned with time and the
sequencing of operations – events that mark changes, states that define the
context for events, and the organization of events and states. Actions and events
in a state diagram become operations on objects in the class model. State
diagram describes the state model.
3. Interaction Model:
Interaction model is used to show the various interactions between objects, how
the objects collaborate to achieve the behavior of the system as a whole.
The following diagrams are used to show the interaction model:
CLASS
OBJECTS
ENCAPSULATION
POLYMORPHISM
INHERITANCE
ABSTRACTION
Class − A class is a data-type that has its own members i.e. data members and
member functions. It is the blueprint for an object in object oriented programming
language. It is the basic building block of object oriented programming in c++. The
members of a class are accessed in programming language by creating an instance of
the class.
Some important properties of class are −
Class is a user-defined data-type.
A class contains members like data members and member functions.
Data members are variables of the class.
Member functions are the methods that are used to manipulate data members.
Data members define the properties of the class whereas the member functions
define the behaviour of the class.
4
A class can have multiple objects which have properties and behaviour that in
common for all of them.
Syntax
class class_name {
data_type data_name;
return_type method_name(parameters);
}
Object − An object is an instance of a class. It is an entity with characteristics and
behaviour that are used in the object oriented programming. An object is the entity
that is created to allocate memory. A class when defined does not have memory
chunk itself which will be allocated as soon as objects are created.
Syntax
class_name object_name;
5
Function overloading Functions with the same name that can do multiple types based
on some condition.
Inheritance it is the capability of a class to inherit or derive properties or
characteristics other class. it is very important and object oriented program as it allows
reusability i.e. using a method defined in another class by using inheritance. The class
that derives properties from other class is known as child class or subclass and the class
from which the properties are inherited is base class or parent class.
C plus plus programming language supports the following types of inheritance
single inheritance
multiple inheritance
multi level inheritance
Hierarchical inheritance
hybrid inheritance
Abstraction Data abstraction or Data Hiding is the concept of hiding data and showing
only relevant data to the final user. It is also an important part object oriented
programing.
let's take real life example to understand concept better, when we ride a bike we only
know that pressing the brake will stop the bike and rotating the throttle will accelerate
but you don't know how it works and it is also not think we should know that's why this
is done from the same as a concept data abstraction.
In C plus plus programming language write two ways using which we can accomplish
data abstraction −
using class
using header file