C++ LAB

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7

PART- B

PROGRAM 1 PROGRAM 2 PROGRAM 3 PROGRAM 4 PROGRAM 5 PROGRAM 6 PROGRAM 7 PROGRAM 8

old

PROGRAM 8 PROGRAM 9 PROGRAM 10 PROGRAM 11 PROGRAM 12 PROGRAM 13 PROGRAM 14 . . .

simple, parameterized,copy constructor

 

#include < iostream.h >  
using namespace std;  
class A  
{  
   public:  
    int x; 
    A(){ x=0;}
    A(int a)                // parameterized constructor.  
    {  
      x=a;  
    }  
    A(A &i)               // copy constructor  
    {  
        x = i.x;  
    }  
};  
int main()  
{  
  A a1(20);               // Calling the parameterized constructor.  
 A a2(a1);                //  Calling the copy constructor.  
 cout<< a2.x;  
  return 0;  
}