0% found this document useful (0 votes)
19 views

PreReview Lecture

1. The document discusses several key OOP concepts including data types, classes, encapsulation, memory allocation, constructors, inheritance, and polymorphism. 2. It explains primitive and user-defined data types like structures and arrays, as well as how to define classes with member variables and functions. 3. Multiple concepts of OOP are demonstrated through code examples like defining classes for cars with member functions to insert and display data, using constructors to initialize member variables, and inheriting classes from a base class.

Uploaded by

Abhishek Modi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

PreReview Lecture

1. The document discusses several key OOP concepts including data types, classes, encapsulation, memory allocation, constructors, inheritance, and polymorphism. 2. It explains primitive and user-defined data types like structures and arrays, as well as how to define classes with member variables and functions. 3. Multiple concepts of OOP are demonstrated through code examples like defining classes for cars with member functions to insert and display data, using constructors to initialize member variables, and inheriting classes from a base class.

Uploaded by

Abhishek Modi
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 10

OOPs Concepts

Date: 13/01/11 Pre-Review

Data Type
1. Primitive Data type : Int , Float, Char int x ; float y ; char z ; 2. Array : for storing more than one data of same type. int x[10] ; 3. Structure : for storing more than one data of different type. struct node { int x ; int y ; }; struct node n ; n.x n.y

Contd..
Class node { int x; int y; display() { x; y; } }; node n ; n.x ; n.y ; n.display() ;

Class
class car { private: int carno; public: insert() { cin >> carno ; } display () { cout << carno; } }; main() { Data Member Member Function car c; c.carnoAccess specifiers = 5; (security c.insert(); of members ) c.display(); private } public Class car { int carno ; }
Default private

Encapsulation

Memory Allocation
class car { int carno ; int carmodel ; int no of wheel ; int no of gate ; int no of seat ; carno carmodel displaycarno() { cout << carno ; } displaynoofwheel() { cout << no of wheel ; } insert () { cin >> carno >> carmodel >> no of wheel >> no of gate >> no of seats ; } };

main() { car maruti ; maruti.insert();gate wheel car santro; santro.insert(); car tata ; tata.insert();. maruti.displaycarno(); . . }

seat

Initialization of Data in Class


Class car { private : int x, y ; public : car () { x = 10; y = 20; } car (int i ) { x=i; y = i + 50; } car (int i, int j ) { x=i; y=j; } }; 10 20

main () { car c ; car m(70); car CONSTRUCTOR k( 5, 10); . . Default Constructor . . } Parameterized Constructor

Class car { private : int x ; int y ; public : void display () ; void display (int x) ; }; Void car : : display ()

Scope Resolution & Overloaded Operator


main() { car C1, C2, C3 ; C1 = C2 + C3 ; . } Overloaded
Operator Overloaded Function
C1.x = C2.x + C3.x C1.y = C2.y + C3.y

{ cout << x << y ;

Polymorphism
Two type: 1. Static 2. Dynamic Static : a) Operator Overloading b) Function Overloading Dynamic : Virtual Function

Inheritance
POINT

LINE

POLYGONE

SQUARE

RECTANGLE

HEXAGONE

Thats all for today.. Thanks !

You might also like