#include <iostream>
template <unsigned, unsigned> class Screen;
template <unsigned H, unsigned W>
std::ostream& operator<<(std::ostream&,
const Screen<H, W>&);
template <unsigned H, unsigned W>
std::istream& operator>>(std::istream&,
const Screen<H, W>&);
template <unsigned H, unsigned W>
class Screen {
friend std::ostream& operator<<<H, W>
(std::ostream&, const Screen<H, W>&);
friend std::istream& operator>><H, W>
(std::istream&, const Screen<H, W>&);
public:
Screen(): height(0), width(0) { }
private:
std::size_t height, width;
};
template <unsigned H, unsigned W>
std::ostream& operator<<(std::ostream& os, const Screen<H, W>& val)
{
os << val.height << " " << val.width;
return os;
}
template <unsigned H, unsigned W>
std::istream& operator>>(std::istream& is, const Screen<H, W>& val)
{
is >> val.height >> val.width;
return is;
}
int main()
{
Screen<50, 20> derp;
std::cin >> derp;
std::cout << derp;
return 0;
}
So, I get this error from the code above,
there was no problem if the "std::cin >> derp;" line is removed, it means it could work with std::cout, but why not std::cin??