Tuesday 16 April 2013

COPY CONSTRUCTOR

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

class code
{
  int id;
  public:
  code()
  {

  }
  code(int a)
  {
   id=a;
  }
  code(code & x)
  {
   id=x.id;
  }
  void display(void)
  {
    cout<<id;
  }
};
int main()
{
  clrscr();
  code a(10);

  code b(a);
  code c=a;
  code d;
  d=c;

  cout<<"\n\n\t Id Of A ";
  a.display();

  cout<<"\n\n\t Id Of A ";
  b.display();

  cout<<"\n\n\t Id Of A ";
  c.display();

  cout<<"\n\n\t Id Of A ";
  d.display();

  getch();
}

No comments:

Post a Comment

How to change Background color by selecting color from Listview

activitymain.xml file::> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"     xm...