sahajjain01

Declare class item to store item no. and name of 5 objects

Mar 27th, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.63 KB | None | 0 0
  1. //Program to declare class item to store item number and name of 5 objects.
  2. #include<iostream.h>
  3. #include<conio.h>
  4. #include<stdio.h>
  5. class item
  6. {
  7.        private:
  8.        int item_no;
  9.        char item_name[80];
  10.        public:
  11.        void getdata()
  12.        {
  13.           cout<<"Enter item number: ";
  14.           cin>>item_no;
  15.           cout<<"Enter item name: ";
  16.           gets(item_name);
  17.        }
  18.        void putdata()
  19.        {
  20.     cout<<"Item number is: "<<item_no<<endl;
  21.     cout<<"Item name is: ";
  22.     puts(item_name);
  23.     cout<<endl;
  24.        }
  25. };
  26.  
  27. void main()
  28. {
  29.     item a,b;
  30.     a.getdata();
  31.     b.getdata();
  32.     a.putdata();
  33.     b.putdata();
  34.     getch();
  35. }
Advertisement
Add Comment
Please, Sign In to add comment