how to create inheritance using c++

What is CPP?

Cpp programming  (pronounced see plus plus) is general-purpose programming language. Cpp programming is regarded as a "middle-level" language, as it comprises a combination of both high-level and low-level language features. It was developed by Bjarne Stroustrup starting in 1979 at Bell Labs as an enhancement to the C programming language and originally named C with Classes. It was renamed Cpp programming in 1983.
As one of the most popular programming languages ever created, C++  programming is widely used in the software industry. Some of its application domains include systems software, application software, device drivers, embedded software, high-performance server and client applications, and entertainment software such as video games.  






Cpp practice work example,Cpp class example,CPP example,cpp class example,cpp programs


Here you will find cpp programs and cpp class example.This is just example you can modify this cpp class example.


cpp programs

cpp source codes for how to create inheritance using CPP

/******************************************
      author-Nikunj v Gandhi
      from-gujarat(surat)
      Web Developer(PHP ZCE)
      email-nik_gandhi007@yahoo.com
      http//my-source-codes.blogspot.com
      description:how to use inheritance using c++ language  
      *******************************************/
 
      #include<conio.h>
      #include<stdio.h>
      #include<nik.h>
      #include<iostream.h>
      class person
 {
   char name[50],gen[6];
   int age;
   public:
     person(){}
     void get_info();
     void put_info();
 };
      void person::get_info()
 {
   cout<<"Enter the name of person?";
   gets(name);
   cout<<"Enter the gender of person?";
   cin>>gen;
   cout<<"Enter the age of person?";
   cin>>age;
 }
     void person::put_info()
      {
 cout<<name<<"t";
 cout<<gen<<"t";
 cout<<age<<"t";
      }
      class employee:protected person
       {
  int empid;
  long sal;
  char des[20];
  public:
    employee(){}
    void get_info();
    void put_info();
 };
      void employee::get_info()
 {
   person::get_info();
   cout<<"Enter emp id?";
   cin>>empid;
   cout<<"Enter salary?";
   cin>>sal;
   cout<<"Enter designation?";
   gets(des);
 }
     void employee::put_info()
       {
  person::put_info();
  cout<<empid<<"t";
  cout<<sal<<"t";
  cout<<des<<"n";
       }
     class student:protected person
       {
  int studid;
  char class_name[10];
  public:
   void get_info();
   void put_info();
 };
     void student::get_info()
       {
  person::get_info();
  cout<<"Enter stud id?";
  cin>>studid;
  cout<<"enter student class name?";
  gets(class_name);
       }
     void student::put_info()
       {
  person::put_info();
  cout<<studid<<"t";
  cout<<class_name<<"n";
 }
     void main()
      {
 clrscr();
 nik();
 employee e;
 cout<<"nnENTER EMPLOYEE INFORMATIONnn";
 e.get_info();
 student p;
 cout<<"nnENTER STUDENT INFORMATIONnn";
 p.get_info();
 cout<<"n NAMEtGENDERtAGEtEMPIDtSALARYtDESIGNATIONn";
 e.put_info();
 cout<<"n NAMEtGENDERtAGEtSTUDIDtCLASS NAMEn";
 p.put_info();
      }

Buy Me a Beer-If you are like this post

 If you does not have paypal account create free account create account

No comments:

Post a Comment