C++ Programming Tutorial

 
 
 

Object Oriented Programming

Structures

Example of structures Passing structures to function Passing structure pointers to function Pointers and an array of structure Relationship between union and structure Array of structure Nested structures Self-referential structures Linked List

Classes

Classes with inline functions Classes without using inline functions Example of constructor in classes Passing values to constructor in classes Overloading of constructors in classes Example of destructor in classes Example of static class data Example of static member functions Constant objects, constant member functions Strings as member of classes Use of arrays as data items in classes Example of array of objects in classes Use of pointer this using header file this.h Obj initialize, assign by default member wise copy

Inheritance - Containership

Example of Inheritance Over riding base class member fn in derived Diff in public, protected, private inheritance Multi-level inheritance Multiple inheritance Example of containership

Virtual Functions - Polymorphism

Example of Polymorphism Example of Pure Virtual functions

Operator Overloading - Type Casting

Increment operator ++ overloading w/o return type Increment operator ++ overloading - return type Decrement operator -- overloading w/o return type Decrement operator -- overloading - return type Operator overloading for strings Comparision operator < overloading Binary operator + overloading creating new object Binary operator + overloading w/o creating object Binary operator - overloading creating object Binary operator - overloading w/o creating object Binary operator * overloading w/o creating object Stream insertion >> , extraction << operators Data conversion b/w built-in data types Data conversion - built-in, user defined data type Conversion- built-in, user defined data type- char Data conversion user defined data type - function Conversion user defined data type - constructor

Friend Functions and Classes

Use of friend functions Use of friend classes Operator overloading using friend function All Operator overloading using friend function Addition of 2 matrix using friend function Example of friend function of a class

Template Functions and Classes

Interchange value using function template Example of template classes Template based array input Template to find minimum value in an array Template of vector class

File Processing - Command Line Arguments

Open file File operation program - diff type of mode Read from one text file, writing in new text file File read, write, update and display operations Read decimal from file - convert into hexadecimal Read words from file and remove palindrome Read device data from text file and show extension Example of binary files

General Programs

Number of days b/w two given dates Capitalize first charcter of every word in string Copy n num of characters from one to another Word is palindrome or not using classes & pointers Simulation of the Solar System Add and Subtract functions on Big Number Class
 
 

Image

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

 const int length=50;


 //------------------------------  student  ------------------------------//


 class student
    {
       private:
        char school[length];
        char degree[length];

       public:
        void get_education();
        void show_education();
    };



 //------------------------------  employee  -----------------------------//


 class employee
    {
       private:
        char name[length];
        char id_number[length];

       public:
        void get_identification();
        void show_identification();
    };


 //------------------------------  manager  ------------------------------//


 class manager
    {
       private:
        char title[length];
        double club_dues;

        student stu;
        employee emp;

       public:
        void get_data();
        void show_data();
    };


 //------------------------------  scientist  ----------------------------//


 class scientist
    {
       private:
        int publications;

        student stu;
        employee emp;

       public:
        void get_data();
        void show_data();
    };


 //------------------------------  labour  -------------------------------//


 class labour
    {
       private:
        employee emp;

       public:
        void get_data();
        void show_data();
    };



 //-----------------------  get_education( )  ----------------------------//


 void student::get_education()
    {
       cout<<\"\\t Enter the School Name : \";
       gets(school);

       cout<<\"\\t Enter the highest Degree earned : \";
       gets(degree);
    }


 //-----------------------  show_education( )  ---------------------------//


 void student::show_education()
    {
       cout<<\"\\t School Name : \"<<school<<endl;
       cout<<\"\\t Highest Degree earned : \"<<degree<<endl;
    }



 //---------------------------  employee  --------------------------------//




 //----------------------  get_identification( )  ------------------------//


 void employee::get_identification()
    {
       cout<<\"\\t Enter the Name : \";
       gets(name);

       cout<<\"\\t Enter the ID Number : \";
       gets(id_number);
    }


 //----------------------  show_identification( )  -----------------------//


 void employee::show_identification()
    {
       cout<<\"\\t Name : \"<<name<<endl;
       cout<<\"\\t ID Number : \"<<id_number<<endl;
    }



 //----------------------------  manager  --------------------------------//




 //----------------------------  get_data( )  ----------------------------//


 void manager::get_data()
    {
       emp.get_identification();

       cout<<\"\\t Enter the Title : \";
       gets(title);

       cout<<\"\\t Enter the Club Dues : \";
       cin>>club_dues;

       stu.get_education();
    }


 //----------------------------  show_data( )  ---------------------------//


 void manager::show_data()
    {
       emp.show_identification();

       cout<<\"\\t Title : \"<<title<<endl;
       cout<<\"\\t Club Dues : \"<<club_dues<<endl;

       stu.show_education();
    }



 //----------------------------  scientist  ------------------------------//




 //----------------------------  get_data( )  ----------------------------//


 void scientist::get_data()
    {
       emp.get_identification();

       cout<<\"\\t Enter the Number of Publications : \";
       cin>>publications;

       stu.get_education();
    }


 //---------------------------  show_data( )  ----------------------------//


 void scientist::show_data()
    {
       emp.show_identification();

       cout<<\"\\t Number of Publications : \"<<publications<<endl;

       stu.show_education();
    }



 //-----------------------------  labour  --------------------------------//




 //----------------------------  get_data( )  ----------------------------//


 void labour::get_data()
    {
       emp.get_identification();
    }


 //---------------------------  show_data( )  ----------------------------//


 void labour::show_data()
    {
       emp.show_identification();
    }


 main()
    {
       clrscr();

       manager m;
       scientist s;
       labour l;

       cout<<\"\\n *********  Manager  *********\"<<endl;
       m.get_data();

       cout<<\"\\n *********  Scientist  ********\"<<endl;
       s.get_data();

       cout<<\"\\n *********  Labour  ********\"<<endl;
       l.get_data();

       getch();
       clrscr();

       cout<<\"\\n *********  Manager  *********\"<<endl;
       m.show_data();

       cout<<\"\\n *********  Scientist  ********\"<<endl;
       s.show_data();

       cout<<\"\\n *********  Labour  ********\"<<endl;
       l.show_data();

       getch();
       return 0;
    }

    Related Post:
  1. Program to illustrate the use of the break statement

  2. Program to solve the mystery of Towers of Hanoi using recursion

  3. Program to perform array operations like append, insert, delete, edit, display and search and element

  4. Program that creats a 3D solid object using Rotational Sweep Representatiom Method

  5. Program to show the 3D Reflection Transformation along yz-plane

  6. Program that takes input of vector elements and performs multiplication operation, and input/output (&gt;&gt;, &lt;&lt;) using operator overloading

  7. Program to create a queue using static memory allocation

  8. Program to determine whether the given function is a Cubic Spline or not

  9. Program of inheritance using shape class and area calculation

  10. Program to find largest integer among the three and display it using function with no return type

  11. Program of addition and subtraction of large numbers

  12. Program to show the projection of 3D objects using Standard Perspective Projection w.r.t. an Arbitrary Plane and Center of Projection...

  13. Program to illustrate virtual function and Inheritance

  14. Program of traversing a binary tree in inorder, preorder and postorder fashion

  15. Program to construct and display the Divided Difference Table from the given distinct data points.

  16. Program of SCANNER

  17. Menu driven telephone directory program

  18. Program to read two numbers from the keyboard and display larger value

  19. Program to generate a triangular wave form according to a specified pair of Amplitude and Frequency

  20. Program to read n integers and add them up and output the result

 
 
Didn't find what you were looking for? Find more on Program to illustrate an example of containership