by Dinesh Thakur Category: Classes in C++

 

#include<iostream.h>

#include<conio.h>
#include<string.h>
class employee
{
                char name [80 ];//private by default
  public:
                void putn(char *n);//these are public
                void getn(char *n);
  private:
                double wage;
  public:
                void putw(double w);
                double getw();
};
            void employee::putn(char *n)
        {
            strcpy(name,n);
        }
            void employee::getn(char *n)
        {
            strcpy(n,name );
        }
            void employee::putw(double w)
        {
            wage =w;
         }
             double employee::getw()
         {
             return wage;
          }
              void main()
             {
                 clrscr();
                 employee emp;
                 char name [80];
                 emp.putn("Rani");
                 emp.putw(25000);
                 emp.getn(name);
                 cout <<name <<" makes $";
                 cout <<emp.getw()<<" per year.";
                 getch();
             }

Define Class Employee

About Dinesh Thakur

Dinesh ThakurDinesh Thakur holds an B.SC (Computer Science), MCSE, MCDBA, CCNA, CCNP, A+, SCJP certifications. Dinesh authors the hugely popular blog. Where he writes how-to guides around Computer fundamental , computer software, Computer programming, and web apps. For any type of query or something that you think is missing, please feel free to Contact us.



Search Content







Popular Article