Hey all I keep getting this error in my istream overload function:
ColorBlob.cpp: In function 'std::istream& operator>>(std::istream&, ColorBlob&)':
ColorBlob.cpp:204:17: error: cannot bind 'std::istream {aka std::basic_istream<char>}' lvalue to 'std::basic_istream<char>&&'
In file included from c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/min
gw32/4.7.1/include/c++/iostream:41:0,
from Color.h:14,
from ColorBlob.h:13,
from ColorBlob.cpp:11:
c:\program files (x86)\codeblocks\mingw\bin\../lib/gcc/mingw32/4.7.1/include/c++
/istream:866:5: error: initializing argument 1 of 'std::basic_istream<_CharT,
_Traits>& std::operator>>(std::basic_istream<_CharT, _Traits>&&, _Tp&) [with _Ch
arT = char; _Traits = std::char_traits<char>; _Tp = Color**]'"
My function is defined as follows:
istream& operator>>(istream& istrm, ColorBlob& CB){
double red,blue,green;
cout << "Enter red value";
cin >> red;
cout << "Enter green value";
cin >> green;
cout << "Enter blue value";
cin >> blue;
CB.setColor(Color(red, green, blue));
istrm >> CB.width;
istrm >> CB.height;
istrm >> CB.data;
return istrm;
}
The error is happening on "istrm >> CB.data", but it is taking the width and height fine.
ColorBlob->data is a dynamic 2D array of Colors.