Reputation: 1712
I have searched high and low, but have not found an answer, so please excuse if this is a duplicate.
I have some very old C++ code that I am trying to lightly convert into this millennium. The code still compiles in Visual Studio 6 and needs to continue doing so, but I am also trying to get it working in Visual Studio 2017. I have done this before, but with many changes to the header files etc., this time I am trying a more measured approach.
The code already uses a mix of stl and non-stl, old and new io headers etc., so it's a mess waiting to explode.
As a simple start, I just replaced iostream.h with iostream to see what would happen. I got some compiler errors where the code had ::ostream in it, so changing that to std::ostream fixed that issue. Next I get an issue with an overloaded << operator, all of the bits in there are using std::iostream, but it seems that the << commands are trying to use ostream instead (or basic_ostream).
What am I missing? I assume I have to change out some more header files that are importing the old io classes.
inline std::ostream& operator<<(std::ostream& os, const PrinterInfo& pi)
{
os << pi.Idx() << ": " << pi.Name() << ", "
<< PrinterInfo::MapPrinterType(pi.GetPrinterType()) << ", "
<< PrinterInfo::MapPaperType(pi.GetPaperType()) << ", "
<< PrinterInfo::MapPrintFormat(pi.GetPrintFormat()) << ", "
<< PrinterInfo::MapRasType(pi.GetRasType()) << ", "
<< PrinterInfo::MapNPS(pi.NPS()) << ", "
<< "dpx = " << pi.Duplex() << ", "
<< "tray = " << pi.Tray2() << ", "
<< "port = " << pi.PortNo();
return os;
}
The PrinterInfo class has an override for the << operator as well:
inline std::ostream& operator<<(std::ostream& os, const PrinterOption& po)
{
os << "(" << po.Installed() << ", " << po.Enabled() << ")";
return os;
}
Upvotes: 1
Views: 410
Reputation: 97
I dont know if that is the case but if you implement the body of a function INSIDE the class header file remove the inline keyword, i had a similar problem and i waste 2-3 whole days and a lot of recoding to realise this...
Upvotes: 1