Ankit wrote:
> Hello,
>
> I have an old VC++ project code base which I am trying to build and
> use. This uses an ostream object. Now in my project, I have overloaded
> the leftshift operator ( << ), basically being used to "put" data to
> the stream object. However, while I run the app, it does not call the
> correct implementation of the operator. For example, say I have
> following piece of code:
>
> ostream o;
> int i = 4;
> const char* temp = "Test String";
>
> o << i;
>
> o << temp;
> // this call fails. because it does not call the (const char*)
> //implementation, rather calls (const double*) implementation
> //for the operator <<
Well, that's not possible -- char* is not convertible to double*
without a cast. Do you perhaps means that it is calling the void*
overload?
Please post your exact code that implements the overloads
and calls them. The above code can't be correct (o can never
be put to any useful purpose).
It's not possible to add overloads to std:

perator<< . All you can
do is to define :

perator<< for ostream and const char*, and
hope that your compiler selects it instead of std:

perator<< .
Try writing your call as:
:

perator<<(o, temp);
and see if it then chooses the right functions.
Also, include <iostream> (not iostream.h which is a non-standard
header). You might also find things easier if you don't do a "using
namespace std;" until you get your problem sorted out.