PROGRAM TO IMPLEMENT CONCEPT OF CONSTRUCTORS
/*PROGRAM TO IMPLEMENT CONCEPT OF CONSTRUCTORS*/ #include<conio.h> #include<iostream.h> class abc { int a,b; public: abc() { a=b=0; } abc(int x,int y) { a=x; b=y; } abc(abc &m) { a=m.a; b=m.b; …
/*PROGRAM TO IMPLEMENT CONCEPT OF CONSTRUCTORS*/ #include<conio.h> #include<iostream.h> class abc { int a,b; public: abc() { a=b=0; } abc(int x,int y) { a=x; b=y; } abc(abc &m) { a=m.a; b=m.b; …
/*PROGRAM TO IMPLEMENT CONSTRUCTOR OVERLOADING*/ #include<iostream.h> #include<conio.h> class rectangle { int length,breadth; public: rectangle() { length=breadth=0; cout<<“**Constructor with zero argument called**”<<endl<<endl; } rectangle(int a) { length=breadth=a; cout<<“**Constructor with one argument …
/*PROGRAM TO IMPLEMENT COPY CONSTRUCTOR*/ #include<conio.h> #include<iostream.h> class abc { int a,b,sum; public: abc() { cout<<“Enter a: “; cin>>a; cout<<“Enter b: “; cin>>b; } abc(abc &m) { a=m.a; b=m.b; cout<<“a= …
/*PROGRAM TO IMPLEMENT CONSTRUCTOR WITH DEFAULT ARGUMENTS*/ #include<conio.h> #include<iostream.h> class student { int roll_no; float marks; public: student(int x=10,float y=40) { roll_no=x; marks=y; } void display() { cout<<“Roll no: “<<roll_no<<endl; …
/*PROGRAM TO IMPLEMENT PARAMETERIZED CONSTRUCTOR*/ #include<iostream.h> #include<conio.h> class area { int length,breadth; public: area(int l,int b) { length=l; breadth=b; cout<<“Length of rectangle is:”<<length<<endl; cout<<“Breadth of rectangle is: “<<breadth<<endl; } void …
/*PROGRAM TO IMPLEMENT DEFAULT CONSTRUTOR*/ #include<conio.h> #include<iostream.h> class area { int l,b; public: area() { cout<<“Enter length of rectangle: “; cin>>l; cout<<“Enter breadth of rectangle: “; cin>>b; } void display() …
/*PROGRAM TO SHOW CONCEPT OF OUTER FUNCTION FRIEND OF TWO CLASSES*/ #include<conio.h> #include<iostream.h> class tempB; class tempA { int a; public: void get_a() { cout<<“Enter a: “; cin>>a; } friend …
/*PROGRAM TO SHOW CONCEPT OF FRIEND CLASS*/ #include<conio.h> #include<iostream.h> class tempA { int a; public: void get_a() { cout<<“Enter a: “; cin>>a; } friend class tempB; }; class tempB { …
/*PROGRAM TO SHOW THE CONCEPT OF FUNCTION OF ONE CLASS FRIEND OF ANOTHER CLASS*/ #include<conio.h> #include<iostream.h> class xyz; class abc { public: void frnd_fun(xyz x); }; class xyz { int …
/*PROGRAM TO IMPLEMENT BINARY SEARCH*/ #include<conio.h> #include<iostream.h> class binry_srch { int n,low,high,mid,srch,i,a[10]; public: void input(); void result(); …