Logo 
Search:

C++ Programming Articles

Submit Article
Home » Articles » C++ Programming » Object Oriented ProgrammingRSS Feeds

Program of displaying product inventory by converting one class to another class

Posted By: Easy Tutor     Category: C++ Programming     Views: 4695

Write a program that displays product inventory by converting one class to another class.

Code for Program of displaying product inventory by converting one class to another class in C++ Programming

//Conversion from CLASS TO CLASS

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

class invent1
{
 int code;
 int items;
 float price;

  public:

  invent1()
  {}

  invent1(int a,int b,int c)
  {
    code=a;
    items=b;
    price=c;
  }

  void display()
  {
    cout<<"\nCode  : "<<code;
    cout<<"\nItems : "<<items;
    cout<<"\nPrice : "<<price;
  }

  int getcode()
  {return code;}

  int getitem()
  {return items;}

  int getprice()
  {return price;}

};


class invent2
{
  int code;
  floatvalue;

   public:

    invent2()
    {
      code=0;
      value=0;
    }

    invent2(int x,float y)
    {
      code=x;
      value=y;
    }

    void display()
    {
     cout<<"Code  : "<<code<<endl;
     cout<<"Value : "<<value<<endl;
    }

    invent2(invent1 p)
    {
     code=p.getcode();
     value=p.getitem()*p.getprice();
    }
};


void main()
{
 clrscr();
 invent1 s1(100,5,140);
 invent2 d1;

 d1=s1;  //Invoke Constructor in Invent2 for conversion

 cout<<"\nProduct details - Invent1 type";
 s1.display();

 cout<<"\n\n\nProduct details - Invent2 type\n";
 d1.display();
 getch();
}
  
Share: 



Easy Tutor
Easy Tutor author of Program of displaying product inventory by converting one class to another class is from United States. Easy Tutor says

Hello Friends,

I am Free Lance Tutor, who helped student in completing their homework.

I have 4 Years of hands on experience on helping student in completing their homework. I also guide them in doing their final year projects.

I have share many programs on this website for everyone to use freely, if you need further assistance, than please contact me on easytutor.2ya [at the rate] gmail [dot] com

I have special discount scheme for providing tutor services. I am providing tutor service to students from various contries, currently most of my students are from United States, India, Australia, Pakistan, Germany, UK and Canada.

I am also here to expand my technical network to receive more opportunity in my career, make friends to help them in resolving their technical problem, learn and share my knowledge, If you like to be my friend, Please send me friend request.

Thanks,
Happy Programming :)

 
View All Articles

 
Please enter your Comment

  • Comment should be atleast 30 Characters.
  • Please put code inside [Code] your code [/Code].

 
No Comment Found, Be the First to post comment!