Friday, 26 January 2018

Write a program to create a copy constructor. A constructor should be created, then a second constructor should be created which should have values of the previous constructor

#include<iostream>
using namespace std;

class con 
{
    int a,b;
    public:

    con(int x,int y)           
    {
        a=x;
        b=y;
    }

    void Display()   
    {
        cout<<"\nValue of a & b is :"<<a<<"   "<<b;
    }
};

int main()               
{
   con ob(10,20);
   con ob2=ob;

   ob.Display();
   ob2.Display();

   return 0;
}

No comments:

Post a Comment

It's time To increase blogging capability. To have a chance to contribute in digital world. Any Interested People who want to make t...