Write a program that will demonstrate assigning objects

Bismillahir Rahmanir Rahim
Assignment 2:
Write a program that will demonstrate assigning objects. The program that uses the following properties- class name- B, integer type private member variable- c, d, two public member functions- set_data(int m, int n), display(), two objects- e, f. 
The output will be:
67 55
67 55
 Solution:

#include<iostream.h>
class B
{
 int c,d;
 public:
 int setdata(int m,int n)
 {
  c=m;
  d=n;
  return (c,d);
 }
 void disply()
 {
  cout<<c<<"\t"<<d<<endl;
 }
};
void main()
{
 B e,f;
 e.setdata(67,55);
 f=e;
 e.disply();
 f.disply();
}

Socializer Widget By Blogger Yard
SOCIALIZE IT →
FOLLOW US →
SHARE IT →