PreReview Lecture
PreReview Lecture
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
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 ()
Polymorphism
Two type: 1. Static 2. Dynamic Static : a) Operator Overloading b) Function Overloading Dynamic : Virtual Function
Inheritance
POINT
LINE
POLYGONE
SQUARE
RECTANGLE
HEXAGONE