hi all,
when i run the program in console when i want to enter value the emp_name,basic are skipping and hra,da,gross,net are not calculating,pls give me solution where i am wrong?

thank you in advance.
the programme is :

#include <iostream>
#include<stdio.h>


using namespace std;


    class Employee
    {
        protected:
        char emp_id,emp_name;
        double basic,lic,pf;
         //float hra,da,gross,net;
        public:
        void get()
        {
            cout<<"enter the emp_id::";
            cin>>emp_id;

            cout<<"enter the emp_name::";
            cin>>emp_name;

            cout<<"enter the basic::";
            cin>>basic;

            cout<<"enter lic::";
            cin>>lic;

            cout<<"enter the pf::";
            cin>>pf;
        }


    };
    class Show:public Employee
        {   public:
            void get2()
            {
                cout<<"empid::"<<emp_id<<endl;
                cout<<"empname::"<<emp_name<<endl;
                cout<<"lic::"<<lic<<endl;
                cout<<"pf::"<<pf<<endl;

            }
        };
        class Salary:public Employee
        {
            protected:
            double hra,da,gross,net;
            public:
            void get1()
            {



                hra=basic*0.1;
                da=basic*0.15;
                gross=basic+da+hra;
                net=gross-lic-pf;
                cout<<"hra: "<<hra<<endl;
                cout<<"da: "<<da<<endl;
                cout<<"gross: "<<gross<<endl;
                cout<<"net : "<<net<<endl;
            }
        };


int main()
{
    cout << "payroll in hierarchical inheritance "<< endl<<endl;
    cout<<"---------------------------------------------"<<endl<<endl;
    Salary s1;
    Show s;

    cout<<"enter the details::";

    s1.get();
    s.get2();
    s1.get1();

    return 0;
}

Edited 3 Years Ago by Dani: Formatting fixed

when i want to enter value the emp_name,basic are skipping

It wouldn't skip if you enter a single character because they have a char datatype... try string

Edited 4 Years Ago by zeroliken: n/a

This article has been dead for over six months. Start a new discussion instead.