Eighth step for Learning C++ Programming CLASS Friend Overloading vs Overriding Protected Polymorphism
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
friend int printfoo( foo &f1); }; Friend Declaration class foo { private: int i,j; … friend class fee; friend int printfoo( foo &f1); }; 11/2014
[ practice 1 Friend ]
[ explain 1 Friend ]
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); }
[ practice 2 method overriding (1/2) ]
[ practice 2 method overriding (2/2) ]
[ explain 2 method overriding ]
[ practice 3 Overriding & Overloading ]
[ explain 3 Overriding & Overloading ]
[ practice 4 Protected (1/2) ]
[ practice 4 Protected (2/2) ]
[ explain 4 Protected ]