C++ Tutorials

Constructor for Multiple Object in C++ 0

Constructor for Multiple Object in C++

Program 1 // Test Constructor for multiple Object #include<iostream> #define clrscr() system(“cls”) using namespace std; class Test { int n; public: Test() { cout<<” I am constructor\n”; n=10; } void incr() { ++n; }...

Multiple if else Statement in C++ 0

Multiple if else Statement in C++

Program 1 // Program for Nested if else #include<iostream> #define clrscr() system(“cls”) using namespace std; int main() { int a,b,c; cout<<“Enter three number”; cin>>a>>b>>c; if(a>b && a>c) cout<<“Grater number is “<<a; else if(b>c) cout<<“Grater...

C++ Program on Dynamic Memory Allocation 0

C++ Program on Dynamic Memory Allocation

Program 1 // Program for Dynamic Memory allocation using new and delete #include<iostream> #define clrscr() system(“cls”) using namespace std; int main() { int *ar,n,i,sum=0; clrscr(); cout<<“\nEnter limit of array”; cin>>n; ar=new int[n]; //dynamic memory...

C++ Program on Template Pointer 0

C++ Program on Template Pointer

Program 1 // Program for tempalte pointer #include<iostream> #define clrscr() system(“cls”) using namespace std; template<class T> void swap(T *a,T *b); int main() { clrscr(); int a=100,b=50; char ch1=’X’,ch2=’Y’; double d1=50.10,d2=30.10; cout<<“\nBefore swaping: “<<a<<” “<<b;...

C++ Program on Templates 0

C++ Program on Templates

Program 1 // Program for class tempalte #include<iostream> #define clrscr() system(“cls”) using namespace std; template<class T,class V> class Test { T n; V n1; public: Test(T m,V m1) { n=m; n1=m1; } void display()...

Relational Operator Overloading in C++ 0

Relational Operator Overloading in C++

Program 1 //Program for Relational operator overloading // How to compare to object #include<iostream> #define clrscr() system(“cls”) using namespace std; class Test { int n; public: Test(int n) { this->n=n; } Test(Test &k) {...