Download presentation
Presentation is loading. Please wait.
1
Eighth step for Learning C++ Programming
CLASS Friend Overloading vs Overriding Protected Polymorphism
2
A Class can declare other classes as "friend classes".
Friends A Class can declare other classes as "friend classes". A Class can declare external functions as "friends". friends can access private members and methods. 11/2014
3
friend int printfoo( foo &f1); };
Friend Declaration class foo { private: int i,j; … friend class fee; friend int printfoo( foo &f1); }; 11/2014
4
[ practice 1 Friend ]
5
[ explain 1 Friend ]
6
Overloading vs Overriding
- allows creating several methods with the same name which differ from each other in the type of the input and the output of the function. Polymorphism way. Overriding - allows a child class to provide a specific implementation of a method that is already provided by one of its parent classes Overloading Overriding method name same type or number of parameter different return type same or different class C { public : void test(int a); void test(char b); } class D : public C { public : void test(int a); int test(int a); }
7
[ practice 2 method overriding (1/2) ]
8
[ practice 2 method overriding (2/2) ]
9
[ explain 2 method overriding ]
10
[ practice 3 Overriding & Overloading ]
11
[ explain 3 Overriding & Overloading ]
12
[ practice 4 Protected (1/2) ]
13
[ practice 4 Protected (2/2) ]
14
[ explain 4 Protected ]
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.