The program defines two classes, Human and Coder, where Coder is derived from Human. The Human class has a public method eat() which prints the string "Eating..." to the console. The Coder class has a public method code() which prints the string "Coding..." to the console. In the main function, an object c1 of class Coder is created. The eat() and code() methods of c1 are then called.
#include<iostream> using namespace std; class Human { public: void eat() { cout<<"Eating..."<<endl; } }; class Coder: public Human { public: void code() { cout<<"Coding..."; } }; int main(void) { Coder c1; c1.eat(); c1.code(); return 0; }To download raw file Click Here
Eating... Coding...
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions