C++ Declare class item to store item number and name of 5 objects

How to write a Program to declare class item to store item number and name of 5 objects in  C++ Programming ?


Program to declare class item to store item number and name of 5 objects
Program to declare class item to store item number and name of 5 objects


Solution:
//Program to declare class item to store item number and name of 5 objects.
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
class item
{
       private:
       int item_no;
       char item_name[80];
       public:
       void getdata()
       {
     cout<<"Enter item number: ";
     cin>>item_no;
     cout<<"Enter item name: ";
     gets(item_name);
       }
       void putdata()
       {
cout<<"Item number is: "<<item_no<<endl;
cout<<"Item name is: ";
puts(item_name);
cout<<endl;
       }
};

void main()
{
item a,b;
a.getdata();
b.getdata();
a.putdata();
b.putdata();
getch();
}

This C++ Program to declare class item to store item number and name of 5 objects in  C++ Programming.


Learn More :