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>


 //------------------------------  item  ---------------------------------//


 class item
    {
       private:
        char part_name[20];
        float part_price;

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


 //------------------------------  sales  --------------------------------//


 class sales
    {
       private:
        float sales_fig[3];

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


 //---------------------------  hardware_item  ---------------------------//


 class hardware_item:public item,public sales
    {
       private:
        char category[10];
        char manufacturers[10];

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


 //--------------------------  software_item  ----------------------------//


 class software_item:public item,public sales
    {
       private:
        char category[10];
        char operating_system[10];

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



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


 void item::get_data()
    {
       cout<<\"\\t Enter part name = \";
       gets(part_name);

       cout<<\"\\t Enter part price = \";
       cin>>part_price;
    }


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


 void item::show_data()
    {
       cout<<\"\\t Part name = \"<<part_name<<endl;
       cout<<\"\\t Part price = \"<<part_price<<endl;
    }



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


 void sales::get_data()
    {
       cout<<\"\\n Enter the Sales figures for three months : \"<<endl;

       for(int count=0;count<3;count++)
      {
         cout<<\"\\t Sales for month  \"<<count+1<<\" = \";
         cin>>sales_fig[count];
      }
    }


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


 void sales::show_data()
    {
       cout<<\"\\n Sales figures for three months : \"<<endl;

       for(int count=0;count<3;count++)
       cout<<\"\\t Sales for month  \"<<count+1<<\" = \"<<sales_fig[count]<<endl;
    }



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


 void hardware_item::get_data()
    {
       item::get_data();

       cout<<\"\\t Enter the category = \";
       gets(category);

       cout<<\"\\t Enter the manufacturers = \";
       gets(manufacturers);

       sales::get_data();
    }


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


 void hardware_item::show_data()
    {
       item::show_data();

       cout<<\"\\t Category = \"<<category<<endl;
       cout<<\"\\t Manufacturers = \"<<manufacturers<<endl;

       sales::show_data();
    }



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


 void software_item::get_data()
    {
       item::get_data();

       cout<<\"\\t Enter the category = \";
       gets(category);

       cout<<\"\\t Enter the operating system = \";
       gets(operating_system);

       sales::get_data();
    }


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


 void software_item::show_data()
    {
       item::show_data();

       cout<<\"\\t Category = \"<<category<<endl;
       cout<<\"\\t Operating system = \"<<operating_system<<endl;

       sales::show_data();
    }

 main()
    {
       clrscr();

       hardware_item h;
       software_item s;

       cout<<\"\\n ********* Hardware Item ********\"<<endl;
       h.get_data();

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

       getch();
       clrscr();

       cout<<\"\\n ********* Hardware Item ********\"<<endl;
       h.show_data();

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

       getch();
       return 0;
    }

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

  2. Program that reads 10 students marks and displays average, lowest and highest marks

  3. Program that provides an example of passing objects to function using call by reference method

  4. Program of Graphical Representation of Stack And Queue

  5. Program to estimate the Integral value of the function at the given points from the given data using Simpsons 1/3 Rule

  6. Program to create a queue using static memory allocation

  7. Program to illustrate the implementation of arrays as a Linear Queue ( in graphics )

  8. Program of parser 1

  9. Program to illustrate operator overloading from String object to basic string

  10. CREATING A LIST OF THE BOOKS AND THEIR DETAILS AND ACCEPTING DETAILS FROM THE CUSTOMER AND SEARCHING THE BOOKS

  11. Program that provides example of dynamic constructor

  12. Program that provides an example of inheritance using private data

  13. Program to illustrate the implementation of Double Ended linked list as a Stack

  14. Program to illustrate the implementation of array as a Circular Queue

  15. Represent a polynomial in terms of a singly linked list and then add two three variables polynomials

  16. Program that are completely portable across different operating systems

  17. Double Linked List-C++

  18. Prims algorithm for minimum spanning tree

  19. Program which read device data from a text file and show each extension\’s dues

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

 
 
Didn't find what you were looking for? Find more on Program to illustrate multiple inheritance