Original Post
I''ve written a map editor, and separated it into 3 classes: image, font (which uses image), and map (which uses image). I''ve also written STL stream operators for my classes, so that I can stream them to and from disk. However, I am getting this really odd error:
- null_pointer Sabre Multimedia
quote:Irritating, no? Here is the operator in which the error occurs:
MSVC error message c:\program files\microsoft visual studio\myprojects\battle force\editor\source\operators.cpp(86) : error C2679: binary ''<<'' : no operator defined which takes a right-hand operand of type ''class std::map,class std::allocator >'' (or there is no acceptable conversion)
std::ostream& operator<<(std::ostream& os, map& map)
{
os << map.map_size.cx << map.map_size.cy;
os << map.tile_size.cx << map.tile_size.cy;
os << map.images;
os << map.tiles;
os << map.objects;
return( os );
}
Here are my operators:
std::ostream& operator<<(std::ostream& os, map& map);
std::istream& operator>>(std::istream& is, map& map);
std::ostream& operator<<(std::ostream& os, map::script& script);
std::istream& operator>>(std::istream& is, map::script& script);
std::ostream& operator<<(std::ostream& os, map::tile& tile);
std::istream& operator>>(std::istream& is, map::tile& tile);
std::ostream& operator<<(std::ostream& os, map::object& object);
std::istream& operator>>(std::istream& is, map::object& object);
std::ostream& operator<<(std::istream& os, std::map& images);
std::istream& operator>>(std::istream& is, std::map& images);
std::ostream& operator<<(std::ostream& os, std::vector& tiles);
std::istream& operator>>(std::istream& is, std::vector& tiles);
std::ostream& operator<<(std::ostream& os, std::vector& objects);
std::istream& operator>>(std::istream& is, std::vector& objects);
I have implementations for all of those (I''ve checked and double-checked). If I move those operators to the global namespace, I get 2 errors (the same one, plus the istream version of it). How come?
- null_pointer Sabre Multimedia