A
Aleks D
Take a look at the following code:
std::istream& operator>>(std::istream& in, char* str) {
int i=0;
for (char c; str && in.get(c) && c==str; ++i)
; //get consumes the characters from the stream
if (str) {
in.setstate(std::ios_base::failbit);
std::cerr<<"problem with consuming"<<str; //debugging code
}
return in;
};
namespace SimpleSketch {
istream& operator >>(std::istream& is, SimpleGraph& graph) {
is>>"ImgWd = "; //line A
/* .... */
}
}
This code crashes on line A. But if I put the definition of the
operator >> inside the namespace SimpleSketch, it works.
Unfortunately the code is in another file, so that makes things highly
inconvenient. How can I make the caller code work without modifying or
copying the source of the operator.
I am programming on MSVC++.NET
Cheers,
Aleks D.
P.S. this relates to a post from a couple of months ago.
std::istream& operator>>(std::istream& in, char* str) {
int i=0;
for (char c; str && in.get(c) && c==str; ++i)
; //get consumes the characters from the stream
if (str) {
in.setstate(std::ios_base::failbit);
std::cerr<<"problem with consuming"<<str; //debugging code
}
return in;
};
namespace SimpleSketch {
istream& operator >>(std::istream& is, SimpleGraph& graph) {
is>>"ImgWd = "; //line A
/* .... */
}
}
This code crashes on line A. But if I put the definition of the
operator >> inside the namespace SimpleSketch, it works.
Unfortunately the code is in another file, so that makes things highly
inconvenient. How can I make the caller code work without modifying or
copying the source of the operator.
I am programming on MSVC++.NET
Cheers,
Aleks D.
P.S. this relates to a post from a couple of months ago.