A
Ankit
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;
// this calls the correct implementation, i.e. the one which takes int
argument
o << temp;
// this call fails. because it does not call the (const char*)
//implementation, rather calls (const double*) implementation
//for the operator <<
I have no clue why this happens. Actually the code drives a class form
ostream and writes to that rather than writing to ostream (as in the
above piece of code). I wrote a sample test program with a similar
class hierarchy as the one present in the old code base. The calls in
the test program map to the correct implementations, unlike the actual
code base.
Does anyone has a clue as to why this could happen or how should I try
and debug this? I will appreciate any kind of
help/comments/suggestions.
Thanks a ton in advance,
Ankit
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;
// this calls the correct implementation, i.e. the one which takes int
argument
o << temp;
// this call fails. because it does not call the (const char*)
//implementation, rather calls (const double*) implementation
//for the operator <<
I have no clue why this happens. Actually the code drives a class form
ostream and writes to that rather than writing to ostream (as in the
above piece of code). I wrote a sample test program with a similar
class hierarchy as the one present in the old code base. The calls in
the test program map to the correct implementations, unlike the actual
code base.
Does anyone has a clue as to why this could happen or how should I try
and debug this? I will appreciate any kind of
help/comments/suggestions.
Thanks a ton in advance,
Ankit