This program defines two classes Account and Programmer where Programmer inherits Account. The Account class has a salary attribute and the Programmer class has a bonus attribute in addition to the salary attribute inherited from Account. The program then creates an object p1 of Programmer class and prints its salary and bonus.
#include<iostream> using namespace std; class Account { public: float salary = 80000; }; class Programmer: public Account { public: float bonus = 6000; }; int main(void) { Programmer p1; cout<<"Salary: "<<p1.salary<<endl; cout<<"Bonus: "<<p1.bonus<<endl; return 0; }To download raw file Click Here
Salary: 80000 Bonus: 6000
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions