Saturday, 11 June 2016

How to learn OOP by CPP(C Plus Plus) Project in C++

Leave a Comment
Instructions:

Below mention code is compiled in Code Blocks and Visual Studio 2015 and output snap is attached.. If any problem you feel and want explanation feel free to contact.

Code:

/**************************************************|
/*************C++ Programs And Projects************|
***************************************************/
#include<stdlib.h>
#include<iostream>
#include<string.h>
#include<conio.h>
#include<stdio.h>
#pragma warning(disable:4996)
#pragma warning(disable:4700)
using namespace std;

//************* -CONCEPT OF CLASS & OBJECT********************
void cl_ob()
{
       int c = 1;
       for (; !c == 0;)
       {
              // clrscr();
              cout << "\t-------------CONCEPT OF CLASS & OBJECT------------";
              cout << "\n\n\n1) What is class & object?\n\n2)  What is the jeneral format of them?\n\n";
              cout << "3) Show example.\n\n";
              //cout<<"\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nCLASS:- \n\nClass is a basic bulding block of \
 object-orinted programming.\nIt is an abstraction that captures the \
 common structure and common behaviour of a set of objects\n\n \
 \n\n\nOBJECT:-\n\nAn objects is somthing that has an identity,\
 a state,and a behaviour.The state is member variables\n\
 or data members and the behaviour is member functions.\n\n\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }

              case 2:
              {
                     cout << "\n\n\nGENERAL FORMAT OF CLASS:-\n";
                     cout << "class class_name{\n\n    private data & functions\
 \n\n\tacess specifier:data & functions\n\n\tacess specifier:data & functions\
 \n\n\t......\n.......\n};\n\n\n";
                     cout << "GENERAL FORMAT OF OBJECT:-\n\n\n";
                     cout << "class_name obj_name\n\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     //       clrscr();
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\n\t\t\t\
\n\ninclude<iostream.h>\n\nclass test{\nint a;\npublic:\n\nvoid get(){a=10;}\
\nvoid print(){cout<<a;}\n\n\t};\n\n\nvoid main(void)\n{\ntest X;\n\
X.get();\nX.print();\n}\n\n\t\t\t<1 for run ,0 for back>\n\n\nENTER YOUR CHOICE FOR\
EXAMPLE:-       ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           class test {
                                  int a;
                           public:
                                  void get() { a = 10; }
                                  void print() { cout << a; }
                           };
                           test X;
                           X.get();
                           cout << "\nINPUT:-\n10\nOUTPUT:-\n";
                           X.print();
                           cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                           getch();
                           break;
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              }
       }
}
//**************  FEATURES OF OOP-*********************

void feature(void)
{
       int c = 1;
       for (; !c == 0;)
       {
              //    clrscr();
              cout << "--------------FEATURES OF OOP---------------\n\n\n";
              cout << "1. Abastraction\n\n2. Encapsulation\n\n3. Dynamic binding\n\n4. Inheritance ";
              cout << "\n\n\n\n\t\t\t\t\t\t<<0 for quit\n\n\n";
              cout << "ENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\t-------------ABSTRACTION------------";
                           cout << "\n\n\n1) What is abstraction?\n\n2) Why used abstraction?\n\n";
                           cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
                           cout << "\n\n\nENTER YOUR CHOICE:      ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nABSTRACTION:-\n\nThe ability for a program to ignore\
 some aspects of the information .That mean's ,abstraction is the ability \
to focus the essential.\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n Abstraction is used to focus essentials in a program.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           }
                     }
                     break;
              }
              case 2:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\t-------------ABSTRACTION------------";
                           cout << "\n\n\n1) What is encaptulation?\n\n2) Why used encaptulation?\n\n";
                           cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
                           cout << "\n\n\nENTER YOUR CHOICE:      ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\nENCAPSULATION:-\n\n\nEncapsulation meam's information hiding.\
The wrapping up of data and functions into a single unit is known as\
encapsulation.\n\nIt ensures that, objects cannot change the internal\
state of other objects in unexpected ways; only the object's own\
internal methods are allowed to access its state.\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n To hide data or information in a program so that a object\
 can not change other object in unexpected ways is used encaptulation.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           }
                     }
                     break;
              }

              case 3:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\t-------------DYNAMIC BINDING------------";
                           cout << "\n\n\n1) What is dynamic binding?\n\n";
                           cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
                           cout << "\n\n\nENTER YOUR CHOICE:      ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nDYNAMIC BINDING:-\n\nDynamic binding means that, the code \
associated with a given procedure is not known untill the time of the call \
at run time.Function overloading is the example of dynamic binding.Because \
if we use function overloading then before runtime the compiller do not know\
 what function is used.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }

                           }
                     }
                     break;
              }
              case 4:
              {
                     cout << "\n\nINHERITANCE:-\n\nInheritance is the process by which objects\
of one class acquire the properties of objects of another class. It\
supports the concept of hierichal classification or reuseability property.";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              }
       }
}
//********* >PRIVATE,PUBLIC & PROTECTED MEMBERS< *******

void ppp_m()
{
       int m = 1;
       for (; !m == 0;)
       {
              system("cls");
              cout << "-------->PRIVATE,PUBLIC & PROTECTED MEMBERS<-----------\n\n\n";
              cout << "1. Varribales\n\n2. Functions\n\n\n\t\t\t<0 for main menue>\n\n\n\t\
       ENTER YOUR CHOICE:-      ";
              cin >> m;
              switch (m)
              {
              case 1:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\n\n----------------PRIVATE,PUBLIC & PROTECTED VARRIABLES-\
-----------------\n\n\n1> what is private,public & protected varriables?\n\n\
2> why used private,public & protected varribales?\n\n3> show example\n\n\n\t\
\t\t<<0for back>>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nPRIVATE VARRIABLE:-\n\nprivate varribales\
are not accessible directly using dot opetrator.The scope of this varriables\
 are only within class.It can be accessed by only public functions.\n\n\n\
 PUBLIC VARRIABLES:-\n\npublic varribales are accessible directly using dot\
 operator.The scope of this varriables are outside class.Any object or functin\
 can directly access public varriables.\n\n\n PROTECTED VARRIBALES:-\n\nThe\
 feature of protected varribales are same as private varriables.The main\
 difference between private & protected varriavbles are ,private varribles\
 cannot be inherited but protected varribles can be inherited.\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\n1) private varriables are used to data\
hiding.It also help us to not change any data unconciously\n\n2) public varriables\
 are used to access any data directly using dot operator.\n\n3) protected varriables\
 are used for inherit any private data.\n\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  system("cls");
                                  cout << "\n\n---------EXAMPLE ZONE-----------\n\n\n\n";
                                  cout << " #include<conio.h>\n#include<iostream.h>\n\
class test1{\nprotected:\nint  x;\npublic:\ntest1(){x=20;}\n};\n\
class test:public test1{\nint a;\npublic:\nint b;\nvoid get(){a=5;}\nint show()\
{return a*x;}\n};\nvoid main(void)\n{\nclrscr();\ntest B;\ntest1 C;\nB.b=2;\n\
B.get();\n\n\n\ncout<<multiplying a,b & c=<<B.show()*B.b;\n}\n\n\n\t\t\t<1 \
for run o for back>\n\n\nENTER YOUR CHOICE:-          ";
                                  int e;
                                  cin >> e;
                                  if (e == 1)
                                  {
                                         class test1 {
                                         protected:
                                                int  x;
                                         public:
                                                test1() { x = 20; }
                                         };
                                         class test :public test1 {
                                                int a;
                                         public:
                                                int b;
                                                void get() { a = 5; }
                                                int show() { return a*x; }
                                         };
                                         test B;
                                         test1 C;
                                         B.b = 2;
                                         B.get();
                                         cout << "\n\nINPUT:-\na=5,  b=2,  c=20\n\n";
                                         cout << "OUTPUT:-\n\nmultiplying a,b & c=" << B.show()*B.b;
                                         cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                         getch();
                                         break;
                                  }
                                  else if (e == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }

                     }
                     break;
              }
              case 2:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\n\n----------------PRIVATE,PUBLIC & PROTECTED FUNCTION-\
-----------------\n\n\n1> what is private,public & protected member functions?\n\n\
2> why used private,public & protected functions?\n\n3> show example\n\n\n\t\
\t<0for main menu>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nPRIVATE MEMBER FUNCTION:-\n\nprivate member functions\
can not use directly using dot opetrator by any object.The scope of this functions\
 are only within class.It can be accessed by only public functions.\n\n\n\
 PUBLIC MEMBER FUNCTIONS:-\n\npublic member functions are accessible directly\
 using dot operator under the object of that class.The scope of this functoins\
 are outside class.Any object or member functin can directly access public\
 functions.\n\n\nPROTECTED MEMBER FUNCTIONS:-\n\nThe feature of protected\
 member functions are same as private private member functions.The main\
 difference between private & protected functions are,private functions cannot\
 be inherited but protected functions can be inherited.\n\n\n\n\n\n\t\t\t\
 ->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\na) private member functions are used\
for data hiding.It is also used to hide perticular task within a class so that\
 this task are not changed unconsiously.\n\n2) public member functions are\
 used to access any private data and private functions.It can access any data\
 or functions directly.\n\n3) protected member functions are used for inheritance.\
 Protected member\n\n\functions can be inherited & derived class can be use \
 it.\n\n\n\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  system("cls");
                                  cout << "\n\n\n---------EXAMPLE ZONE-----------\n\n\n\n";
                                  cout << "#include<conio.h>\n#include<iostream.h>\nclass\
pro{\nint x;\nprotected:\nint get(){return x;}\npublic:\npro(){x=2;}\n};\
class test:public pro{\nint a;\nint pri(){a=5;return a;}\npublic:\nint c;\
int access(){return pri()*get();}\n};\nvoid main(void)\n{\ntest B;\npro C;\nB.c=2;\
cout<<\n\n\n\nmultiplying a and x, sum=<<B.access();\ngetch();\n}\n\n\n\t\t\t\
<1 for run 0 for back>\n\n\nENTER YOUR CHPICE:-        ";
                                  int e;
                                  cin >> e;
                                  if (e == 1)
                                  {
                                         class pro {
                                                int x;
                                         protected:
                                                int get() { return x; }
                                         public:
                                                pro() { x = 2; }
                                         };
                                         class test2 :public pro {
                                                int a;
                                                int pri() { a = 5; return a; }
                                         public:
                                                int c;
                                                int access() { return pri()*get(); }
                                         };

                                         test2 B;
                                         pro C;
                                         B.c = 2;
                                         cout << "\n\nINPUT:-\n\na=5   x=2\n\nOUTPUT:-\n\n";
                                         cout << "multiplying a and x, sum=" << B.access();
                                         cout << "\n\n\t\t->PRESS ENTER FOR NEXT<-";

                                         getch();
                                         break;
                                  }
                                  else if (e == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }

                     }
              }

              }

       }
}

//************* FUNCTION OVERLOADING ******************


int add(int a, int b) { return a + b; }
double add(double a, double b) { return a + b; }

void over_l()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------FUNCTION OVERLOADING------------";
              cout << "\n\n\n1) What is function overloading?\n\n2) Why used function overloading?\n\n";
              cout << "3) What is the jeneral format of function overloading?\n\n4) Show example.\n\n\n";
              cout << "\n\t\t\t\t<<0 for main menu";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "Function overloading means one name multiple forms.It allows us\
 to have more than one functions with the same name but performs different tasks\
 in a program depending on the argument lists in the function call.The\
 correct function to be invoked is determined by checking the the number and\
 type of the arguments but not on the functions type. \n\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "Function overloading is used for same function name but\
different purposes.By using function overloading consecpt, we can design\
a family of functions with one function name but with different argument lists\
. n\n\n\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\n\n--->->GENERAL FORMAT OF FUNCTION OVERLOADING:<-<---\n";
                     cout << "\n\n\nDECLARATION:-\n\n\ndata_type1 function_name(data_type1);\
\n\ndata_type1 function_name(data_type1,data_type1);\n\ndata_type1 \
function_name(data_type1,data_type2);\n\ndata_type1 function_name\
(data_type2,data_type1);\n\ndata_type1 function_name(data_type2,data_type2);";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 4:
              {
                     system("cls");
                     cout << "\n\t\t\t--------:EXAMPLE ZONE:----------\n\n\n\n\ninclude\
<iostream.h>\n\nint add(int a,int b)\n{\nreturn a+b;\n}\n\ndouble add\
(double a,double b)\n{\nreturn a+b;\n}\n\n\nvoid main(void)\n\n{\n\ncout<<\
after first adding sum=<<add(5,10)<<\n\nafter 2nd adding sum=<<add(5.5,5.4);\
\n}\n\n\t\t\t<<1 for run, 0 for back>>\n\n\n\nENTER YOUR CHOICE FOR EXAMPLE:-  ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           cout << "\nINPUT:-\n\na=5    b=10\n\na=5.2   b=5 \n\n\nOUTPUT:-\n\n";
                           cout << "after first adding sum=" << add(5, 10) << "\n\nafter 2nd adding\
sum=" << add(5.5, 5.4);
                           cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                           getch();
                           break;
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              }
       }
}
//************** DEFAULT PARAMETER *******************

int def(int a, int b = 10)
{
       return a + b;
}

void def_pa()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------DEFAULT PARAMETER------------";
              cout << "\n\n\n1) What is default paramereter?\n\n2) Why used default parameter?\
\n\n3) What is the jeneral format of default parameter?\n\n4) Show example.\
\n\n5)specialty of default parameter.\n\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nDEFAULT PARAMETER:-\n\nDefault parameter is a parameter, where the\
formal parameter is initialize primarily and this value is used if any actual\
 parameter is missed at the time of function calling.If we pass the value for\
 that default parameter as actual parameter then that passing value is used\
 otherwise the primary value is used\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "\n\n\nAt the time of function calling, if we don't pass or \
miss any actual parameter then to perform the task of that function properly\
 we use default parameter.Thus to select a value for primarily and perform\
 the task of that function default parameter is used.\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\n\nGENERAL FORMAT OF DEFAULT PARAMETER:-\n\n";
                     cout << "data_type function_name(data_type varr_name=\
value,data_type varr_name=value)\n\n{\n\n\\body;\n\n}\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 4:
              {
                     system("cls");
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\n\
\n\ninclude<iostream.h>\nint def(int a,int b=10)\n{\n\nreturn a+b;\n\n}\n\n\nvoid main(void)\n{\
\n\n\n\cout<<a+b=<<def(20);\n\n}\n\n\t\t\t<<1 for run, 0 for quit >>\n\n\n\n\
 ENTER YOUR CHOICE FOR EXAMPLE:-  ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           cout << "\nINPUT:-\nas actual parameter a=20\nas default parameterb=10\
\n\nOUTPUT:-\n";
                           cout << "a+b=" << def(20);
                           cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                           getch();
                           break;
                     }
                     else if (e == 0)
                           break;

                     break;
              }
              case 5:
              {
                     cout << "\n\nSPECIALTY OF DEFAULT PARAMETER:-\n\n\n<1> when we initialize\
 any default argument, then only value is used not any varriable.suppose,we \
cannot write the follwing program -\n\nint spesal(int c,int a=10, int b=a)\
{return c+a+b;}\n\nvoid main(void)\n\n{\ncout<<spesal(10);\n\n}\n\n\n\
<2> after one default parameter, we have to use every parameter as default\
 parameter in a function.that means we cannot write following coding -\n\n\
 int spesal(int c=10,int a, int b){return c+a+b;}\n\n\nvoid main(void)\n\n\
 {\ncout<<spesal(10,10);\n\n}\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              }
       }

}
//********** PASSING AND RETURNING OBJECTS *************

class val {
       int x;
public:
       void put_x(int a) { x = a; }
       int get() { return x; }
       void print() { cout << x; }
};
val min(val B)
{
       val temp;
       int a = -B.get();
       temp.put_x(a);
       return temp;
}


class reff {
       int x;
public:
       void put(int a) { x = a; }
       int get() { return x; }
       void print() { cout << x << "      "; }
};

int add(reff *p, reff *q)
{
       int a, b;
       a = p->get();
       b = q->get();
       (*p).put(a + 1);
       (*q).put(b + 1);
       return p->get() + q->get();
}

void pass_ret()
{
       int m = 1;
       for (; !m == 0;)
       {
              system("cls");
              cout << "-------->PASSING AND RETURNING OBJECTS<-----------\n\n\n";
              cout << "1. Pass by value\n\n2. Pass by reference\n\n\n\t\t\t<0 for \
main menue>\n\n\nENTER YOUR CHOICE:-   ";
              cin >> m;
              switch (m)
              {
              case 1:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "1> what is passing & returning by value?\n\n\
2> why used passing & returning by value of objects?\n\n3> Genaral format\
\n\n4> show example\n\n\n\t\t\t<<0for back>>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nPASSING & RETURNING BY VALUE:-\n\nat \
the time of function calling,if we pass value as actual parameter then it is \
call pass by value.And at the time of returning from a function, if we \
return value then it is called return by value.when we use pass by value, \
then a coppy is passed to function, and so if we change the value in\
that function, the main value is not changed.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\nsometime in program, we need to \
change the value of formal parameter in a function,but we need to not change \
that actual value in a function.In this situation we need to use pass by \
value.Because in this case the copy of actual parameter(here object) is \
passed to function.sometime we need to pass or return all the features of a \
class.that time we use an object of that class to pass or return because an \
object of a cllass posses all the features.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  cout << "\n\nGENARAL FORMAT:-\n\n\nclass_name \
function_name(class_name object_name)\n\n{\n\nclass_name object\n\n....\n..\
...\n\nreturn object;\n\n}\n";
                                  getch();
                                  break;
                            }
                           case 4:
                           {
                                  system("cls");
                                  cout << "\n\n\n---------EXAMPLE ZONE-----------\n\n\n\n\
\n#include<iostream.h>\nclass val{\nint x;\npublic:\n\void put_x(int a){x=a;}\
\nint get(){return x;}\nvoid print(){cout<<x;}\n};\n\val min(val B)\n{\nval \
temp;\nint a=-B.get();\ntemp.put_x(a);\nreturn temp;\n}\n\nvoid main(void)\
\n{\nval B,C;\nB.put_x(15);\nC=min(B);\n C.print();\n}";
                                  int e;
                                  cout << "\n\n\nENTER YOUR CHOICE:-   ";
                                  cin >> e;
                                  if (e == 1)
                                  {
                                         cout << "\n\nINPUT:-\n\n  15\n\n\nOUTPUT:-\n\n";
                                         val B, C;
                                         B.put_x(15);
                                         C = min(B);
                                         C.print();
                                         cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                         getch();
                                         break;
                                  }
                                  else if (e == 0)
                                         break;
                                  break;
                           }
                           }
                     }
                     break;
              }
              case 2:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "1> what is passing & returning by reference?\n\n\
2> why used passing & returning by reference of objects?\n\n3> Genaral \
format \n\n4> show example\n\n\n\t\t\t<<0for back>>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nPASSING & RETURNING BY REFERENCE:-\n\n\
at the time of function calling,if we pass address as actual parameter\
then it is call pass by reference.And at the time of returning from a \
function, if we return address then it is called return by reference.when \
we use pass by reference, then a the actual address is passed to function, \
and so if we change the value in that function, the main value is changed.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\nsometime in program, we need to \
change the value of formal parameter in a function,and we want to use that \
change value outside that function in a program.In this situation we need \
to use pass by reference.Because in this case the address of actual \
parameter(here object) is passed to function.sometime we need to pass or \
return all the features of a class.that time we use an object of that\
class to pass or return because an object of a cllass posses all the \
features.moreover if we want to use the changable value of that object \
outside the function then we can use passing & returning object by reference.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";               getch();
                                  break;
                           }
                           case 3:
                           {
                                  cout << "\n\nGENARAL FORMAT OF PASS BY REFERENCE:-\n\
\n\nreturn_type function_name(class_name *object_name)\n\n{\n\n\\\bobyn;\n\n\
\n}\n\n\n\nFUNCTION CALLING:-\n\n\nfunction_name(& object_name);\n\n";
                                  getch();
                                  break;
                           }
                           case 4:
                           {
                                  system("cls");
                                  cout << "\n---------EXAMPLE ZONE-----------\n\n\n\n\
#include<iostream.h>\nclass ref{\nint x;\npublic:\nvoid \
put(int a){x=a;}\nint get(){return x;}\nvoid print(){cout<<x<<"      ";}\n\
};\nint add(ref *p,ref *q)\n{\nint a,b;\na=p->get();\nb=q->get();\n(*p).\
put(a+1);\n(*q).put(b+1);\nreturn p->get()+q->get();\n}\n\nvoid main(void)\
\n{\n ref x,y;\nx.put(5);\ny.put(10);\nint z=add(&x,&y);\nx.print();\n\
y.print();\ncout<<z;\n}\n\n\t\t<1 for run, 0 for back>\n\nENTERYOUR CHOICE:-   ";
                                  int e;
                                  cin >> e;
                                  if (e == 1)
                                  {
                                         cout << "\n\nINPUT:-\n\n5      10 \n\nOUTPUT:-\n\n";
                                         reff x, y;
                                         x.put(5);
                                         y.put(10);
                                         int z = add(&x, &y);
                                         x.print();
                                         y.print();
                                         cout << z;
                                         cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                         getch();
                                         break;
                                  }
                                  else if (e == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }
                     }
              }
              }
       }
}
//*************** CONSTRUCTERS & DESTRUCTORS *****************

void cons_des()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------CONSTRUCTERS & DESTRUCTORS ------------";
              cout << "\n\n\n1) What is constructor & destructor?\n\n2) Why used \
constructor & destructor?\n\n3) What is the jeneral format of them?\n\n\
4) Show example.\n\n5) speciality \n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nCONSTRUCTOR:-\n\nConstructor is a public member \
function which is called implicitly(clmpiller's automatically call is known \
as implicit call but manually call is known as explicit call) when a object \
is created.It's name is same as class name and it has no return type but can \
have parameter.\n\n\nDESTRUCTOR:-\n\nDestructor is a public member function \
which is called implicitly when a object is destructed from memmory.\
Destructor name is same as class name and it has no return type and no \
argument and a tilde(~)charector is situated before it's name.";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "\n\n\nwe know that constructor  & destructor are called \
implictly when an object is created, so we can use them to perform that \
things which is needed all time in a program.suppose, if we want to allocate\
memmory dynamically then we can use constructor and to free memmory we\
can use destructor because the time to create each object constructor is\
called implicitly and allocate memmory for that object and at the time to \
vanish that object destructor is called implictly and free allocated memmory \
for that object.moreover, by using parameterical constructor we can assing\
value for private varriables.";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\n\nGENERAL FORMAT OF CONSTRUCTOR:-\n\n\nDECLARATION:-\n\n\n\
class_name(argument_list);\n\nCALLING:-\n\n*)IMPLICITLY:-    class_name\
(actual_parameter_list);\n\n*)EXPLICITLY:- class_name obj_name=class_name\
(actual_parameter_list);\n\n\n\nGENERAL FORMAT OF DESTRUCTOR:-\n\n\n\
~class_name();";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 4:
              {
                     system("cls");
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\
\n#include<iostream.h>\nclass test{\nint a;\npublic:\ntest(){cout<<\
constructing........;}\n~test(){cout<<destructing......;}\nvoid get()\
{a=10;}\nvoid print(){cout<<a<<endl;}\n};\n\nvoid main(void)\n{\ntest X;\n\
X.get();\nX.print();\n}\n\n\t\t\t<<1 for run, 0 for back >>\n\n\n\nENTER \
YOUR CHOICE FOR EXAMPLE:-  ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           cout << "\nINPUT:-\n   10\nOUTPUT:-\n\n\n";
                           class test {
                                  int a;
                           public:
                                  test() { cout << "constructing........\n"; }
                                  ~test() { cout << "destructing......\n"; }
                                  void get() { a = 10; }
                                  void print() { cout << a << endl; }
                           };
                           {
                                  test X;
                                  X.get();
                                  X.print();
                           }
                           cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                           getch();
                           break;
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              case 5:
              {
                     cout << "If there is a constructor with one parameter then we can use\
     assingment operator(=) as follows\n\nclass_name obj_name=actual_parameter.\n\n ";
                     cout << "EXAMPLE:-\n\n\nclass special{\nint x;\npublic:\nspecial(int a){x=a;}\n\
     void print(){cout<<x;}\n};\n\nvoid main(void)\n{\nspecial ob=5;\nob.print();\n}\n\
     \n\nINPUT:-\n5\n\nOUTPUT:-\n5\n\n";
                     getch();
                     break;
              }
              }
       }
}
//****************** FRIEND FUNCTION ***********************

class complex {
       int x, y;
public:
       complex() {}
       complex(int r, int i) { x = r; y = i; }
       void print() { cout << "after adding:     " << x << "+i" << y; }
       friend complex add(complex, complex);
};
complex add(complex a, complex b)
{
       complex z;
       z.x = a.x + b.x;
       z.y = a.y + b.y;
       return z;
}


void fr_function()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------FRIEND FUNCTION------------";
              cout << "\n\n\n1) What is friend function?\n\n2) special charectaristics \
of friend function\n\n3) Why used friens function?\n\n4) What is the jeneral \
format of friend function?\n\n5) Show example.\n\n6) special case\n\n\n\
\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:-      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nFRIEND FUNCTION:-\n\nFriend function is generally a \
nonmember function but can access any private or public data & functions \
using dot operator.It is declared within class but defined outside class.\
The keyword 'friend' is used before function return type at the time to \
declare but not used at the time to defined.";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "\n\n\nSPECIAL CHARECTERISTICS OF FRIEND FUNCTION:-\n\n\
a> Friend function is not in the scope of the class to which it is declared \
as friend\n\b>It cannot be called using the object of the class c> Called \
like normal function\n\nd) cannot directly access members\n\ne) Friend \
function may be either public or private\n\nf) usally it has object as \
arguments\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "1. operator overloading\n\n2. make the creation of some \
I/Ofunctions easily(like template)\n\n3.Two or more class objects interect \
each other.\n";
                     getch();
                     break;
              }
              case 4:
              {
                     cout << "\n\n\nGENERAL FORMAT OF FRIEND FUNCTION:-\n\nclass class_name\
{\n....\n......\npublic:\nfriend return_type function_name(parameter_list);\
\n\n.....\n.....\n\n};\n\nreturn_type function_name(parameter_list)\n\
{\nbody\n}\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 5:
              {
                     system("cls");
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\ninclude<iostream.h>\
\nclass complex{\nint x,y;\npublic:\ncomplex(){}\ncomplex(int r,int i)\
{x=r;y=i;}\n\nvoid print(){cout<<after adding:     <<x<<+i<<y;}\n\
friend complex add(complex,complex);\n};\n\ncomplex add(complex a,complex b)\
\n{\ncomplex z;\nz.x=a.x+b.x;\nz.y=a.y+b.y;\nreturn z;\n}\n\nvoid main(void)\
\n{\ncomplex p(2,3),q(4,5),r;\nr=add(p,q);\nr.print();\n}\n\n\n\t\t\t<<1 \
for run, 0 for back>>\n\n\n\nENTER YOUR CHOICE FOR EXAMPLE:-  ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           cout << "\n\nINPUT:-\n2+i3\n4+i5\n\nOUTPUT:-\n\n";
                           complex p(2, 3), q(4, 5), r;
                           r = add(p, q);
                           r.print();
                           cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                           getch();
                           break;
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              case 6:
              {
                     system("cls");
                     cout << " \nSPECIAL CASE:-\n1)friend function has no 'this' pointer \

and instead of 'this' pointer reference is used there.0\n\n2)we can use \a member function of a class as a friend function of another class.Then we \
have to use scope resulation operator(::)to define that function and have to \
use dot operator to call that function.It is the special case.EXAMPLE:-\n\n\
class A;\nclass X{\nint x;\npublic:\nX(){}\nX(int a){x=a;}\nvoid max(A);\n};\
\n\nclass A{\nint a;\npublic:\nA(){}\nA(int p){a=p;}\nfriend void X::max(A);\
\n};\nvoid X::max(A q)\n{\nif(x>q.a)\ncout<<x;\nelse\ncout<<q.a is greater \
number\n;\n}\nvoid main(void)\n{\n X x(10);\nA y(12);\nx.max(y);\n}\n\n\
INPUT:-\n10   12\naOUTPUT:-\n12 is greater number\n";
                     cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              }
       }
}
//****************** FRIEND CLASS *******************

class A {
       int a;
public:
       A(int m) { a = m; }
       friend class B;
};
class B {
       int b;
public:
       B(int n) { b = n; }
       int mul(A);
};
int B::mul(A x)
{
       return x.a*b;
}

void fr_class()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------FRIEND CLASS------------";
              cout << "\n\n\n1) What is friend class?\n\n2) Why used friend class?\n\n";
              cout << "3) What is the jeneral format of friend class?\n\n4) Show example.\n\n\n";
              cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nFRIEND CLASS:- \n\nIf there is two class class A and class B\
,and class B is the friend of class A then,all of the member function of class B\
can use all of the private member of class A.  \n\n\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "\n\nIf we want to use all of the membr function of a class as\
 friend function of another class then it is very difficult to write friend \
 keyword before every function.In this situation we can use friend class.\
 It is very helpful to use all the member function of a class as friend of \
 another class.\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\n\nGENERAL FORMAT OF FRIEND CLASS:-\n";
                     cout << "\n\nfriend class class_name;\n\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 4:
              {
                     system("cls");
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\n\n\
#include<iostream.h>\nclass A{\nint a;\npublic:\nA(int m){a=m;}\nfriend class B;\
\n};\nclass B{\nint b;\npublic:\nB(int n){b=n;}\nint mul(A);\n};\nint B::mul(A x)\
\n{\nreturn x.a*b;\n}\nvoid main(void)\n{\nB p(10);\nA q(10);\ncout<<p.mul(q);\
\n}\n\n\t\t\t<<1 for run 0 for exit >>\n\n\n\nENTER YOUR CHOICE FOR EXAMPLE:-  ";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           B p(10);
                           A q(10);
                           cout << "INPUT:-\na=10   b=10\nOUTPUT:-\n";
                           cout << p.mul(q);
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              }
       }
}
//************* 'this' POINTER  *********************

class t_pointer {
       int x, y, z;
public:
       t_pointer(int a, int b) { x = a; y = b; }
       t_pointer add() { z = x + y; return *this; }
       void print() { cout << z; }
};
void this_ptr()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t-------------'this' POINTER------------";
              cout << "\n\n\n1) What is this pointer?\n\n2) Why used this pointer?\n\n";
              cout << "3) What is the jeneral format of this pointer?\n\n4) Show example.\n\n\n";
              cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n'this' is a special type of pointer which points to the\
object for which this function is called.this pointer is passed autometically\
 when a member function is called.Infact, it behaves like as implicit argumwnts\
 to all the member functions.suppose:-\n\nclass test{\nint a;\npublic:\ntest(){a=10;}\
\nvoid print(){cout<<a;}\n};\nvoid main(void)\n{\ntest X;\nX.print();\n}\n\n\
In the above program when we write 'X.print();' then actually compller takes\
 it as 'X.print(*this)' and the *this points to the object X. similiarly 'cout\
 <<a' is taken as 'cout<<this->a'.\n'this' pointer can be also called explicitly. ";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "\n\nWhen we call a member function then 'this' pointer is \
passed autometically as argument and that's why we can use the the private\
 varribales for calling object whitout passing explicitly that object.Again\
 when we overload a binary operator using a member function then,we pass\
 only one parameter to the funvction.The other parameter is implicitly passed\
 using 'this' pointer.Moreover when we compare two or more object using a\
 member function then we can return the calling object as result using this\
 pointer. 'this' pointer is used also for cascading.\n\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\n\nGENERAL FORMAT OF THIS POINTER:-\n";
                     cout << "\n\n\n\return *this;";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 4:
              {
                     system("cls");
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n#include<iostream.h>\n\
class t_pointer{\nint x,y,z;\npublic:\nt_pointer(int a,int b){x=a;y=b;}\n\
t_pointer add()\n{\nz=x+y;\nreturn *this;\n}\nvoid print(){cout<<z;}\n};\n\n\
void main(void)\n{\nt_pointer A(10,15);\ncout<<here add() is called by A object\
 and this function returnsthe obj A using this pointer(*this) and again by using 'A.print()'\
 print() is called and so \nsum=;\nA.add().print();\n}\n\n\n\n\t\t\t\t<<1 for run 0 for exit >> ";
                     cout << "\n\n\n\nENTER YOUR CHOICE FOR EXAMP:-";
                     int e;
                     cin >> e;
                     if (e == 1)
                     {
                           t_pointer A(10, 15);
                           cout << "\n\nINPUT:-\n\nx=10   y=15\n\nOUTPUT:-\n\n";
                           cout << "here add() is called by A object and this function returns\
the obj A using this pointer(*this) and again by using 'A.print()'\
print() is called and so sum\nz=";
                           A.add().print();
                           cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     }
                     else if (e == 0)
                           break;
                     getch();
                     break;
              }
              }
       }
}
//********* OPERATOR OVERLOADING ****************

class bin {
       int a, b;
public:
       bin() { a = 0; b = 0; }
       bin(int m, int n) { a = m; b = n; }
       bin operator +(bin);
       void print() { cout << "1st sum=" << a << endl << "2nd sum=" << b; }
};

bin bin::operator+(bin x)
{
       bin p;
       p.a = a + x.a;
       p.b = b + x.b;
       return p;
}


class frnd {
       int a, b;
public:
       frnd() { a = 0; b = 0; }
       frnd(int m, int n) { a = m; b = n; }
       friend frnd operator +(frnd, frnd);
       void print() { cout << a << endl << b; }
};

frnd operator+(frnd x, frnd y)
{
       frnd p;
       p.a = x.a + y.a;
       p.b = x.b + y.b;
       return p;
}


class mem {
       int a, b;
public:
       mem() { a = 0; b = 0; }
       mem(int m, int n) { a = m; b = n; }
       mem operator ++();
       void print() { cout << a << endl << b << endl; }
};

mem mem::operator++()
{
       a++;
       b++;
       return *this;
}


class fru {
       int a, b;
public:
       fru() { a = 0; b = 0; }
       fru(int m, int n) { a = m; b = n; }
       friend void operator ++(fru &);
       void print() { cout << a << endl << b << endl; }
};

void operator++(fru &x)
{
       x.a++;
       x.b++;
}

void op_ovr()
{
       int m = 1;
       for (; !m == 0;)
       {
              system("cls");
              cout << "-----------OPERATOR OVERLOADING><-----------\n\n\n";
              cout << "1. Using member function\n\n2. Using friend function\n\n\n\t\t\t<0 for main menue>\n\n\n\t\
       ENTER YOUR CHOICE:-      ";
              cin >> m;
              switch (m)
              {
              case 1:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\t1> what is operator overloading using member function?\
\n\n2> why use operator over loading?\n\n3>rules of operator overloading\
\n\n4> genaral format\n\n5> show example\n\n\n\t\t\t\<<0for back>>\n\n\n\n\
ENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nOPERATOR OVERLOADING:-\n\nIn C++ user defined\
 data type can be used the same way as the built in data type.suppose, in C++\
 we can add two varriables of user defined types with the same syntax that is\
 applied to the basic type.That is to say,C++ provides the operators with a\
 special meaning for a data type.The process of giving such special meaning\
 to an operator is known as operator overloading.To overload an operator a \
 special function is needed which is called operator function.If we use a\
 member function as this operator function then it is called operator overloading\
 with member function.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\nIn C++ by using operator overloading,\
 we can use the same syntax that is applied to the basic data type for an operator.\
 It provides an easy way to create a new defination and a new meaning for most\
 of the C++ operator.But we should not chnge the main meaning of operator. \
 \n\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  cout << "RULES OF OPERATOR OVERLOADING:-\n\na) The over\
 loaded operator must have at least one user defined operand.\n\nb) Over loaded\
 operator must have follow the syntax rules of original operators.\n\nc) We can\
 not change the original meaning of an operator.\n\nd) Operator function can not\
 have any default argument.\n\ne) When we overload an unary operator then we need\
 not declare any parameter for operator function.\n\nf) Only existing operator\
 can be overloaded.\n\n";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 4:
                           {
                                  cout << "GENARAL FORMAT OF OPERATOR OVERLOADING USING \
 MEMBER FUNCTION:-\n\n\nDECLARATION:-\n\nreturn_type operator overloadable_operator\
(parameter_list);\n\nDEFINATION:-\n\nreturn_type class_name::operator\
 overloadable_operator(parameter_list)\n{\n\n\\body;\n\n}";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 5:
                           {
                                  system("cls");
                                  cout << "\n\n\n---------EXAMPLE ZONE-----------\n\n\n\n\
1. binary operator over loading using member function\n\n2. unary operator \
overloading using member function\n\n\n\n\n\t\t\tENTER YOUR CHOICE:-   ";
                                  int ch;
                                  cin >> ch;
                                  if (ch == 1)
                                  {
                                         cout << "#include<iostream.h>\nclass bin{\nint a,b;\npublic:\nbin(){a=0;b=0;}\n\
bin(int m,int n){a=m;b=n;}\nbin operator +(bin);\nvoid print(){cout<<1st sum=\
<<a<<endl<<2nd sum=<<b;}\n};\n\nbin bin::operator+(bin x)\n{\nbin p;\np.a=a+x.a;\np.b=b+x.b;\nreturn p;\
}\n\n\nvoid main(void)\n{\nbin A(10,20),B(30,40),C;\nC=A+B;\nC.print();\n}\n\n";
                                         int e;
                                         cout << "\n\n\nENTER YOUR CHOICE:-   ";
                                         cin >> e;
                                         if (e == 1)
                                         {
                                                cout << "INPUT:-\n\na=10  b=30\n\na=20   b=40\n\
\n\nOUTPUT:-\n\n";
                                                bin A(10, 20), B(30, 40), C;
                                                C = A + B;
                                                C.print();
                                                getch();
                                                break;
                                         }
                                         else if (e == 0)
                                                break;
                                  }
                                  else if (ch == 2)
                                  {
                                         cout << "#include<iostream.h>\nclass mem{\nint a,b;\npublic:\n\
mem(){a=0;b=0;}\nmem(int m,int n){a=m;b=n;}\nmem operator ++();\n\
void print(){cout<<a<<endl<<b;}\n};\nmem mem::operator++()\n{\na++;\nb++;\n\
return *this;\n}\nvoid main(void)\n{\nmem A(10,20),C;\n++C;\n++A;\n\
C.print();\nA.print();\n}\n";
                                         int e;
                                         cout << "\n\n\nENTER YOUR CHOICE:-   ";
                                         cin >> e;
                                         if (e == 1)
                                         {
                                                cout << "INPUT:-\n\na=0  b=0\n\na=10   b=20\n\
\n\nOUTPUT:-\n\n";
                                                mem A(10, 20), B(30, 40), C;
                                                ++C;
                                                ++A;
                                                C.print();
                                                A.print();
                                                getch();
                                                break;
                                         }
                                         else if (e == 0)
                                                break;

                                  }
                                  else if (ch == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }
                     }
                     break;
              }
              case 2:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "1> what is operator overloading using friendfunction?\n\n\
2> why used friend function for operator overloading?\n\n\3> genaral format\n\n\
4> show example\n\n\n\t\t\t<0for main menu>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nOPERATOR OVERLOADING USING FRIEND FUNCTION:-\n\n\
In C++ user defined data type can be used the same way as the built in data type.suppose, in C++\
 we can add two varriables of user defined types with the same syntax that is\
 applied to the basic type.That is to say,C++ provides the operators with a\
 special meaning for a data type.The process of giving such special meaning\
 to an operator is known as operator overloading.To overload an operator a \
 special function is needed which is called operator function.If we use a\
 friend function as this operator function then it is called operator overloading\
 with friend function.For using this we have to pass all the operand as parameter.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                   cout << "\n\n\nIf we want to add a user defined data\
 type and a built in data type using operator overloading with member function\
 then we must have to use the user defined data type as an left operand.But \
 for the similar case, if we use operator overloading with friend function\
 then there is no such restriction to use operand.It is very easy and comfortable\
 to use such case.And that's why friend function is used as operator function.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  cout << "\n\nGENARAL FORMAT OF OPERATOR OVERLOADING WITH\
 FRIEND FUNCTION:-\n\n\nDECLARATION:-\n\n\nfriend return_type operator\
 overloadable_operator(parameter_list);\n\n\nDEFINATION:-\n\n\n\
return_type operator overloadable_operator(parameter_list)\n{\n\n\\body\n\n}\n";
                                  getch();
                                  break;
                           }
                           case 4:
                           {
                                  system("cls");
                                  cout << "\n\n\n---------EXAMPLE ZONE-----------\n\n\n\n\
1. binary operator over loading using member function\n\n2. unary operator \
overloading using member function\n\n\n\n\t\t\tENTER YOUR CHOICE:-   ";
                                  int ch;
                                  cin >> ch;
                                  if (ch == 1)
                                  {
                                         cout << "#include<iostream.h>\nclass frnd{\nint a,b;\npublic:\nfrnd(){a=0;b=0;}\n\
frnd(int m,int n){a=m;b=n;}\nfriend frnd operator +(frnd,frnd);\nvoid print()\
{cout<<a<<endl<<b;}\n};\n\nfrnd operator+(frnd x,frnd y)\n{\nfrnd p;\n\
p.a=x.a+y.a;\np.b=x.b+y.b;\nreturn p;\n}\n\n\nvoid main(void)\n{\n\
frnd A(10,20),B(30,40),C;\nC=A+B;\nC.print();\n}\n";
                                         int e;
                                         cout << "\n\n\nENTER YOUR CHOICE:-   ";
                                         cin >> e;
                                         if (e == 1)
                                         {
                                                cout << "INPUT:-\n\na=10  b=30\n\na=20   b=40\n\
\n\nOUTPUT:-\n\n";
                                                frnd A(10, 20), B(30, 40), C;
                                                C = A + B;
                                                C.print();
                                                getch();
                                                break;
                                         }
                                         else if (e == 0)
                                                break;
                                  }
                                  else if (ch == 2)
                                  {
                                         cout << "#include<iostream.h>\nclass fru{\nint a,b;\npublic:\
\nfru(){a=0;b=0;}\nfru(int m,int n){a=m;b=n;}\nfriend void operator ++(fru &);\n\
void print(){cout<<a<<endl<<b<<endl;}\n};\n\nvoid operator++(fru &x)\n{\nx.a++;\n\
x.b++;\n}\nvoid main(void)\n{\nfru A(10,20),B(30,40),C;\n++C;\n++A;\nC.print();\n\
A.print();\n}\n";
                                         int e;
                                         cout << "\n\n\nENTER YOUR CHOICE:-   ";
                                         cin >> e;
                                         if (e == 1)
                                         {
                                                cout << "INPUT:-\n\na=0  b=0\n\na=10   b=20\n\
\n\nOUTPUT:-\n\n";
                                                fru A(10, 20), B(30, 40), C;
                                                ++C;
                                                ++A;
                                                C.print();
                                                A.print();
                                                getch();
                                                break;
                                         }
                                         else if (e == 0)
                                                break;


                                         getch();
                                         break;
                                  }
                                  else if (ch == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }

                     }
              }

              }

       }
}

//************** TYPE CONVERSION(Manual type conversion) *********

class con_md {
       int m, d;
public:
       con_md() {}
       con_md(int x) { m = x / 30; d = x % 30; }
       con_md(int a, int b) { m = a; d = b; }
       int get_m() { return m; }
       int get_d() { return d; }
       void print() { cout << "month=" << m << "\tday=" << d; }
};
class con_d {
       int day;
public:
       con_d() {}
       con_d(con_md p) { day = p.get_m() * 30 + p.get_d(); }
       void pr_d() { cout << "\n\n\nday=" << day; }
};


class con_md1 {
       int m, d;
public:
       con_md1() {}
       void put(int a, int b) { m = a; d = b; }
       con_md1(int a, int b) { m = a; d = b; }
       operator int() { return m * 30 + d; }
       void print() { cout << "\nmonth=" << m << "     day=" << d; }
};
class con_d1 {
       int day;
public:
       con_d1() {}
       con_d1(int a) { day = a; }
       int get() { return day; }
       operator con_md1()
       {
              con_md1 temp;
              int m = day / 30;
              int d = day % 30;
              temp.put(m, d);
              return temp;
       }
       void pr_d() { cout << "\nday=" << day; }
};


void type_man()
{
       int c = 1;
       for (; !c == 0;)
       {
              system("cls");
              cout << "\t------------TYPE CONVERSION(Manual type conversion)------------";
              cout << "\n\n\n1) What is manual type conversion?\n\n2) Why used manual type \
conversion?\n\n3)how many process of manual type conversion?\n\n\
4) What is the jeneral format of manual type conversion?\n\n5) Show example.\n\n\n";
              cout << "\n\t\t\t\t\t\t<< 0 for main menue>>";
              cout << "\n\n\nENTER YOUR CHOICE:      ";
              cin >> c;
              switch (c)
              {
              case 1:
              {
                     cout << "\n\n\nTo convert from one data type to another data type to another\
 data type is known as type conversion.In C++,when different built in data type\
 of varriables are mixed in an expression then, automatically type conversion\
 rules(auto cast) is followed.But if we use the combination of user defined data\
 type and built in data type in an expression then we have to convert data\
 manually.The process of this conversion is known as manual type conversion.In\
 manual type conversion we have to design the conversion routines ourselves.";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 2:
              {
                     cout << "When we use the combination of basic data type and user defined\
 data type in an expression to convert data type, we use manual type conversion.\
 In the following three times we have to use the manual type conversion:-\n\n\
 A) Basic type to user defined data type.\n\nB) User defined data type to basic\
 data type.\n\nC) User defined data type to another user defined data type.\n";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 3:
              {
                     cout << "\n\nThere are two way for manual type conversion.As follows:-\n\n\
1)Using constructor function:-\n      Function defination(conversion) is defined\
within destination class.\n\n\n2) Using operator function or conversion\
function:-\n    Function defination(conversion) is defined within source class.\
 Moreover operator function have to stisfy the following condition:\n\na) It must\
be a class member.\n\nb) It must not specify any return type.\n\nc) It must\
not any argument.";
                     getch();
                     break;
              }
              case 4:
              {
                     cout << "\n\n\nGENERAL FORMAT OF MANUAL TYPE CONVERSION:-\n\n1)USING\
 CONSTRUCTOR FUNCTION:-\n\n\nclass_name(parameter_list){  \\conversion;   }\n\n\
\n\n2) USING OPERATOR FUNCTION:-\n\n\noperator type_name()\n{\n\nconversion\n\n}\
\n\n  ";
                     cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                     getch();
                     break;
              }
              case 5:
              {
                     system("cls");
                     int e;
                     cout << "\t\t\t--------:EXAMPLE ZONE:----------\n\n\n\n1) using constructor\
 function.\n\n2)using operator function\n\n\n\t\t\t<<0 for quit>>\
 \n\n\n\nENTER YOUR CHOICE FOR EXAMPLE:-  ";
                     cin >> e;
                     switch (e)
                     {
                     case 1:
                     {
                           system("cls");
                           cout << "#include<iostream.h>\nclass con_md{\nint m,d;\npublic:\ncon_md(){}\
\ncon_md(int x){m=x/30;d=x%30;}\ncon_md(int a,int b){m=a;d=b;}\
\nint get_m(){return m;}\nint get_d(){return d;}\
void print(){cout<<month=<<m<<\nday=<<d;}\n};\nclass con_d{\nint day;\npublic:\
\ncon_d(){}\ncon_d(con_md p){day=p.get_m()*30+p.get_d();}\
void pr_d(){cout<<\nday=<<day;}\n};\nvoid main(void)\n{\ncon_md A,B(3,10);\ncon_d X;\
\nA=100\nA.print();\nX=B;\nX.pr_d();\n}\n\n\n\t\t\t<1 for run 0 for quit>";
                           cout << "\n\nENTER YOUR CHOICE:-       ";
                           int e;
                           cin >> e;
                           if (e == 1)
                           {
                                  con_md A, B(2, 20);
                                  con_d X;
                                  A = 100;
                                  cout << "\n\nINPUT:-\n\nday=100:\n\nmonth=2   day=20\n\nOUTPUT:-\n\n";
                                  A.print();
                                  X = B;
                                  X.pr_d();
                                  getch();
                                  break;
                           }
                           else if (e == 0)
                                  break;
                           getch();
                           break;
                     }
                     case 2:
                     {
                           system("cls");
                           cout << " #include<iostream.h>\nclass con_md{\n\
int m,d;\npublic:\ncon_md(){}\nvoid put(int a,int b){m=a;d=b;}\n\
con_md(int a,int b){m=a;d=b;}\noperator int(){return m*30+d;}\n\
void print(){cout<<\n\nmonth=<<m<<\nday=<<d;}\n};\nclass con_d{\nint day;\n\
public:\ncon_d(){}\ncon_d(int a){day=a;}\nint get(){return day;}\noperator con_md()\
\n{\ncon_md temp;\nint m=day/30;\nint d=day%30;\ntemp.put(m,d);\nreturn temp;\n\
}\nvoid pr_d(){cout<<\nday=<<day;}\n};\nvoid main(void)\n{\nint a;\n\
con_md A(3,10),B(3,10);\ncon_d X(100);\na=A;\ncout<<day=<<a;\nB=X;\nB.print();\
\n}\n\t\t\t<1 for run, 0 for back>\nENTER YOUR CHOICE:-    ";
                           int e;
                           cin >> e;
                           if (e == 1)
                           {
                                  int a;
                                  con_md1 A(3, 10), B;
                                  con_d1 X(100);
                                  a = A;
                                  cout << "\nINPUT:-\nmonth=3    day=10\nday=100\n\nOUTPUT:-\n";
                                  cout << "day=" << a;
                                  B = X;
                                  B.print();
                                  getch();
                                  break;
                           }
                           else if (e == 0)
                                  break;
                           getch();
                           break;
                     }
                     }
              }
              }
       }
}

//************************ REFERENCES ***************************

void new_val(int &x)
{
       x = 100;
}

void refernce()
{
       int m = 1;
       for (; !m == 0;)
       {
              system("cls");
              cout << "------------->REFERENCES<-----------\n\n\n";
              cout << "1. As parameter\n\n2. As return value\n\n3. As independent reference\
\n\n\n\t\t\t<0 for main menue>\n\n\n\n\tENTER YOUR CHOICE:-      ";
              cin >> m;
              switch (m)
              {
              case 1:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\n\n----------------REFERENCE AS FUNCTION PARAMETER-\
-----------------\n\n\n1> what is reference as parameter?\n\n\2> why used\
 reference as parameter?\n\n3> What is the genaral format of reference as parameter\
\n\n4> show example\n\n\n\t\t\t<<0for back>>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)
                           {
                           case 1:
                           {
                                  cout << "\n\n\nREFURENCE AS PARAMETER:-\n\n  Reference\
 varriable is an implicit pointer which provides an alias(alternative name)\
 for a previously defined varrable.In C++, actually reference permits us to\
 use same memmory address by using different name.we can use this reference\
 as function parameter and then it is called reference as function parameter.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 2:
                           {
                                  cout << "\n\n\nThere are two ways to perform call by\
 reference.one is using explicit pointer and another is using reference parameter.\
 Using reference parameter is very easy and comfortable than using explicit\
 pointer.so to perform call by reference very easily, reference parameter is\
 used.";
                                  cout << "\n\n\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                  getch();
                                  break;
                           }
                           case 3:
                           {
                                  cout << "\n\nGENARAL FORMAT OF RRFERENCE PARAMETER:-\n\n\
return_type function_name(data_type &varriable_name,.....)\n{\n\n\\body;\n\n}\n\
\n\nFUNCTION CALLING:-\n\nfunction_name(parameter_list);";
                                  getch();
                                  break;
                           }
                           case 4:
                           {
                                  system("cls");
                                  cout << "\n\n---------EXAMPLE ZONE-----------\n\n\n\n";
                                  cout << "#include<iostream.h>\nvoid new_val(int &x)\n{\n\
x=100;\n}\n\nvoid main(void)\n{\nint a=50;\ncout<<befor function calling a=\
<<a;\nnew_val(a);\ncout<<after function calling(using reference) change value\
 , a=<<a;\n}\n\n\n\t\t\t<1 for run o for back>\n\n\nENTER YOUR CHOICE:-          ";
                                  int e;
                                  cin >> e;
                                  if (e == 1)
                                  {
                                         int a = 50;
                                         cout << "\n\nINPUT:-\n\nbefore function calling a=50\n\nafter function\
calling(using reference) change value , a=100\n\n\nOUTPUT:-\n\n";
                                         cout << "befor function calling a=" << a;
                                         new_val(a);
                                         cout << "\nafter function calling(using reference) change value , a=" << a;
                                         cout << "\n\n\n\t\t\t->->->PRESS ENTER FOR NEXT<-<-<-";
                                         getch();
                                         break;
                                  }
                                  else if (e == 0)
                                         break;
                                  getch();
                                  break;
                           }
                           }

                     }
                     break;
              }
              case 2:
              {
                     int c = 1;
                     for (; !c == 0;)
                     {
                           system("cls");
                           cout << "\n\n----------------REFERENCE AS RETURN VALUE-\
-----------------\n\n\n1> what is reference as return value?\n\n\2> why used \
reference as return value?\n\n3. What is the general format of reference as return\
 value?\n\n4> show example\n\n\n\t\t<0for main menu>\n\n\n\nENTER YOUR CHOICE:-    ";
                           cin >> c;
                           switch (c)

Output:



Related Articles:

C++ Projects

If You Enjoyed This, Take 5 Seconds To Share It

0 Questions:

Labels

Additional Questions Advantages of C Language Advantages of C over C++ and naming them array programs arrays Basic Problems c language projects C plus plus project C Primer Plus c programming sample projects C programs C Projects C Structures C Tutorials C/C++ Shapes C++ Basic Problems C++ Books Solution C++ Functions C++ Language C++ Loops and Decisions C++ Program Examples C++ Programs c++ projects C++ Shapes Code C++ Structures C++ Tips and Tricks C++ Tutorials Control Structures CPP Enum CPP Pointers CPP Vector cppexamples CppStruct Cryptography DataStructures difference between a keyword and a user-defined identifier Disadvantages of C Language Ds malik Ds malik c++ programming Chapter 2: Basic Elements of C++ Solution Ds malik c++ programming Chapter 4: Control Structures I (Selection) Solution else if nested if File Handling in C++ fstream History of C language how to learn c language how to learn c programming Identifiers if statement ifstream language c learn c programming Learn C++ Linked List LinkedList list of all the C++ keywords Loops Loops practice using shapes Magic Squares Puzzle without using Recursion MathProblems nested loop Object Oriented Programming in C++ by Robert Lafore - 4th Edition Chapter 1 Object Oriented Programming in C++ by Robert Lafore - 4th Edition Chapter 2 Object Oriented Programming in C++ by Robert Lafore - 4th Edition Chapter 3 Object Oriented Programming in C++ by Robert Lafore - 4th Edition Chapter 4 Object-Oriented Programming in C++ Fourth Edition Solution Manual ofstream OOP OOP Quiz oop1ch2e oop1ch3e output QTProgramming Recursion Simple C plus plus Programs solution Sorting Strings Temperature 5 Scale Converter Tools of the trade Urdu Training Videos