C++ Programming Blog

 
 
 
# include <iostream.h>
# include <conio.h>
class in1
{
    int code,items;
    float price;
    public:
        in1(int a,int b,int c)
        {
            code=a;
            items=b;
            price=c;
        }
        void putdata()
        {
            cout<<\"CODE= \"<<code<<endl;
            cout<<\"ITEMS= \"<<items<<endl;
            cout<<\"VALUE= \"<<price<<endl;
        }
        int getcode()
        {
            return code;
        }
        int getitems()
        {
            return items;
        }
        int getprice()
        {
            return price;
        }
        operator float ()
        {
             return items*price;
        }
};

class in2
{
    int code;
    float value;
    public:
    in2()
    {
        code=0;
        value=0;
    }
    in2(int x,float y)
    {
        code=x;
        value=y;
    }
    void putdata()
    {
        cout<<\"CODE= \"<<code<<endl;
        cout<<\"VALUE= \"<<value<<endl;
    }
    in2(in1 p)
    {
        code=p.getcode();
        value=p.getitems()*p.getprice();
    }
};

main()
{
clrscr();
    in1 s1(100,51,140.0);
    float tot_value;
    in2 d1;
    tot_value=s1;
    d1=in1(s1);
    cout<<\"PRODUCT DETAILS INVENT-1 TYPES:->\"<<endl;
    s1.putdata();
    cout<<\"STOCK VALUE\"<<endl;
    cout<<\"VALUE= \"<<tot_value<<endl;
    cout<<\"PRODUCT DETAILS INVENT-2 TYPES:->\"<<endl;
    d1.putdata();
}

    Related Post:
  1. Program to show the implementation of Binary Search Tree as Sets

  2. Program that prints first 20 integers (using while loop)

  3. Program to illustrate the use of function overloading

  4. Program that reads a number and displays it with its digits in reverse order using do-while loop

  5. Program to read a Linear System of Equations,then evaluate it by using Gauss-Elimination Method and show the result

  6. Program for Fahrenheit to Celcius

  7. Program to draw a Bezier Curve of nth degree

  8. Program to illustrate the role of constructor in classes

  9. Program to read a Non-Linear equation in one variable, then evaluate it using Bisection Method and display its kD accurate root

  10. Program pf parser 1

  11. Problem you will be analyzing a property of an algorithm whose classification is not known for all possible inputs

  12. Program to estimate the value of First Derivative of the function at the given points from the given data using Central Difference Formula

  13. Program to search an element in an array using Linear search or Sequential Search

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

  15. Program that performs SCANNING of the following program and finds the entire float,integer variables and keywords present in the program

  16. Program to show the projection of 3D objects using Standard Perspective Projection

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

  18. Program of Education System that maintains Institute Database using multilevel inheritance

  19. Program to find the value of sin at any given angle

  20. Program to perform selection sort

 
 
Didn't find what you were looking for? Find more on Program of class to class conversion