N
Ned Harding
In VC7.1 the following code outputs:
00000000
Success!
It would seem that the Y:perator<< is hiding the global operator<<
when it is outputting an object from another namespace but not when it
is outputting an object in the global namespace.
I can't help but think one of these 2 behaviors is a bug in VC7.1, but
which one?
Thanks,
Ned.
=========================================
#include <iostream>
namespace X
{
class Abc1
{
};
}
std:stream& operator<< (std:stream& strm, const X::Abc1 *node)
{
return strm << "Success!";
}
X::Abc1 * GetDoc() { return NULL; }
class Abc2
{
};
Abc2 * GetDoc2() { return NULL; }
std:stream& operator<< (std:stream& strm, const Abc2 *node)
{
return strm << "Success!";
}
namespace Y
{
std:stream & operator<<(std:stream& a, const char& b)
{
return a << "This should not run";
}
void DoTest()
{
std::cout << GetDoc() << "\n";
std::cout << GetDoc2() << "\n";
}
}
int main(int argc, char* argv[])
{
Y:oTest();
return 0;
}
00000000
Success!
It would seem that the Y:perator<< is hiding the global operator<<
when it is outputting an object from another namespace but not when it
is outputting an object in the global namespace.
I can't help but think one of these 2 behaviors is a bug in VC7.1, but
which one?
Thanks,
Ned.
=========================================
#include <iostream>
namespace X
{
class Abc1
{
};
}
std:stream& operator<< (std:stream& strm, const X::Abc1 *node)
{
return strm << "Success!";
}
X::Abc1 * GetDoc() { return NULL; }
class Abc2
{
};
Abc2 * GetDoc2() { return NULL; }
std:stream& operator<< (std:stream& strm, const Abc2 *node)
{
return strm << "Success!";
}
namespace Y
{
std:stream & operator<<(std:stream& a, const char& b)
{
return a << "This should not run";
}
void DoTest()
{
std::cout << GetDoc() << "\n";
std::cout << GetDoc2() << "\n";
}
}
int main(int argc, char* argv[])
{
Y:oTest();
return 0;
}