Wednesday, 30 May 2012

DOWNLOAD ISTREAM AND OSTREAM OVERLOADING.CPP FROM HERE

Other programs :


File operation in c++
Stack Operation in C++
Queue simulation in C++
Use of static keyword in c++
DOWNLOAD BINARY ADDITION AND COPY CONSTRUCTOR.CPP FILE FROM HERE
Binary Search in C++
Operator overloading concept in c++
New and delete operator in c++
Call by value and call-by-refrence in c++
c++ macro:Invoked inline during program execution
Create User Defined Function In C++: Header Files
C++ Polymorphisamusingvirtualfunction


DOWNLOAD BINARY ADDITION AND COPY CONSTRUCTOR.CPP FILE FROM HERE


VISIT SITE LIFEQUEST.COM

Hi friends,

Below program is so simple if you are familiar with operator overloading then it is lot more easy understand,
the idea is that by overloading istream and ostream operator we can directly call cout and cin  the standard  C++ liabrary function  for input/output operation with user defined data data types that is class objeccts.

First it is useful to have a look at this two operator overloading programs:
Operator overloading concept in c++
DOWNLOAD BINARY ADDITION AND COPY CONSTRUCTOR.CPP FILE FROM HERE

Now if  you have understand above two program then now it easy quite easy for you to understand this program.

Let's look at how istream and istrem operator overloading function are declared:

syntax like this:

return-type   operator operator-name(parameter-list);

look below at declaration:

ostream &operator<<(ostream &tcout,matrix &m)



  istream &operator>>(istream &tcin,matrix &m)


DOWNLOAD sourcecode  from here:
DOWNLOAD ISTREAM AND OSTREAM OVERLOADING.CPP FROM HERE

complete code is look like this:


#include <iostream.h>
#include <conio.h>


class matrix
{
private:
 int a;
public:
 friend ostream &operator<<(ostream &tcout,matrix &m);
 friend istream &operator>>(istream &tcin,matrix &m);


};
  ostream &operator<<(ostream &tcout,matrix &m)
{
   tcout<<m.a;
   return tcout;
}




  istream &operator>>(istream &tcin,matrix &m)
{
   tcin>>m.a;
   return tcin;
}


void main()
{
   matrix m;
   clrscr();
   cout<<"Enter integer value :";
   cin>>m;
   cout<<"You entered:"<<endl;
   cout<<m;
   getch();


}



Output snap:

download above program file from here:
DOWNLOAD ISTREAM AND OSTREAM OVERLOADING.CPP FROM HERE


So that is it hope you enjoy it.


Other programs :


File operation in c++
Stack Operation in C++
Queue simulation in C++
Use of static keyword in c++
DOWNLOAD BINARY ADDITION AND COPY CONSTRUCTOR.CPP FILE FROM HERE
Binary Search in C++
Operator overloading concept in c++
New and delete operator in c++
Call by value and call-by-refrence in c++
c++ macro:Invoked inline during program execution
Create User Defined Function In C++: Header Files
C++ Polymorphisamusingvirtualfunction


DOWNLOAD BINARY ADDITION AND COPY CONSTRUCTOR.CPP FILE FROM HERE


VISIT SITE LIFEQUEST.COM