EXP-7 Inheritance and Function Overriding
EXP-7 Inheritance and Function Overriding
#include <iostream>
using namespace std;
class Animal {
public:
void sound() {
cout << "Animal sound" << endl;
}
};
int main() {
Animal a;
a.sound();
Lion l;
l.sound();
return 0;
}
Output:
"Animal sound"
"Roar"
class Parent {
public:
void GeeksforGeeks_Print()
{
cout << "Base Function" << endl;
}
};
int main()
{
Child Child_Derived;
Child_Derived.GeeksforGeeks_Print();
return 0;
}
Output
Derived Function