PROGRAM TO SWAP TWO NUMBERS USING TEMPLATE
/*PROGRAM TO SWAP TWO NUMBERS USING TEMPLATE*/ #include #include using namespace std; template void swap(t1 a,t2 b) { t1 c; c=a; a=b; b=c; cout
/*PROGRAM TO SWAP TWO NUMBERS USING TEMPLATE*/ #include #include using namespace std; template void swap(t1 a,t2 b) { t1 c; c=a; a=b; b=c; cout
/*Program to find the square of any number using DEFAULT ARGUMENT*/ #include #include #include double power(double n,int p=2); int main() { double n; cout
/*Program of Virtual function*/ #include #include class A { int a,b; public: void getdata(int p,int q) { a=p; b=q; cout
/*Program of UNARY operator overloading using friend function*/ #include #include class A { int a,b; public: void getdata(int p,int q) { a=p; b=q; } void display() { cout
/* Program of UNARY OPERATOR OVERLOADING using member function */ #include #include class A { int a,b; public: void getdata(int r,int s) //parameterised constructor { a=r; b=s; } void display() { cout
/*Program of Multilevel Inheritance*/ #include #include class A { int a,b; public: void getdata(int q, int w) { a=q; b=w; } void display() { cout
/*Program of Hierarchical Inheritance*/ #include #include class A { int q; public: void getdata(int w) { q=w; } void display() { cout<<“\n\nq=”<<q<<“\nI am the member of Class A\n”; } }; class B:public A { int e; public: void setdata(int r) { e=r; } void show() { cout<<“\n\ne=”<<e<<“\nI am the member of Class B derived from…
/*Program of Dynamic Constructor*/ #include #include #include class abc { char *string; int length; public: abc() { length=0; string=new char[length+1]; strcpy(string,” “); } abc(char *s) { length=strlen(s); string=new char[length+1]; strcpy(string,s); } void display() { cout
/*Program of BINARY OPERATOR OVERLOADING using Friend function*/ #include #include class A { int a,b; public: void getdata(int c,int d) { a=c; b=d; } void add() { cout
/*Program of VIRTUAL base class*/ #include #include class A { public: A() { cout