Presentation is loading. Please wait.

Presentation is loading. Please wait.

Object Oriented Analysis and Design

Similar presentations


Presentation on theme: "Object Oriented Analysis and Design"— Presentation transcript:

1 Object Oriented Analysis and Design
Object-Oriented Concepts

2 OOAD Concepts Class Object Encapsulation Abstraction Inheritance
Polymorphism Message passing Dynamic binding

3 Classes & Objects Data / attributes / field/state Method / Behaviour
Describe the characteristics Method / Behaviour Perform operations Perform object to object communication

4 Classes & Objects Class Object
Category or group of things that have the same attributes and the same behaviors. Class is a decryption of properties and behaviors which a collection of same type objects can have Object Instance of a class Object is a bundle of properties and behaviors An object stores its state in fields (variables) and exposes its behavior through methods (functions)

5 Classes & Objects Attribute/Field/variable Data/Value Student Nimal
age 21 Study() Study() Class Object

6 Classes & Objects Class Object User defined data type
Instance of user defined data type Prototype or model Containing features Do not occupy memory Occupy memory Cant manipulate since its not in memory Can manipulate

7 Classes & Objects class Student { private : int AM; int EM; public :
void ReadMarks() cout<<"Enter Assignment Marks : "; cin>>AM; } void printGrade() cout<<"Grade :"<<(AM+AM)/2; }; main() { Student Nimal; Nimal.ReadMarks(); Nimal.printGrade(); getch(); }

8 Classes & Objects Member functions defined outside class
Binary scope resolution operator (::) ties member name to class name scope resolution operator help uniquely identifying functions of a particular class Different classes can have member functions with same name

9 Classes & Objects class Student { private : int AM; int EM; public : void ReadMarks(); void printGrade(); }; void Student::ReadMarks() cout<<"Enter Assignment Marks : "; cin>>AM; cin>>AM; } void Student::printGrade() { cout<<"Grade :"<<(AM+AM)/2; } main() Student Nimal; Nimal.ReadMarks(); Nimal.printGrade(); getch();

10 Constructors Constructors are special member functions of any class, which are invoked at the moment an instances of the class are created. They are special functions that have the same name as their class. Have the same name as the class. It may take arguments. It cannot return a value [including void].

11 Constructors Default Constructor Parameterized Constructor
Accepts no parameters Called if no user-defined constructors Parameterized Constructor A constructor that receives arguments/parameters Class:: Circle() {} Circle::Circle(int r) { radius = r;}

12 Destructors Special member function Having same name as class
Preceded with tilde (~) No arguments No return value Cannot be overloaded Invoked before system reclaims object’s memory Used in reusing memory for new objects

13 Pointers Memory location which hold the address of another memory location/ variable int x=5; int *p; p= &x; *p=10;


Download ppt "Object Oriented Analysis and Design"

Similar presentations


Ads by Google