error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const Kula' (or there is no acceptable conversion)
Ostatnio zmodyfikowano 2015-04-13 10:17
gustawson Temat założony przez niniejszego użytkownika |
error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'const Kula' (or there is no acceptable conversion) » 2015-04-13 09:37:46 Witam! Wyświetla mi sie taki bład Error 2 error C2679: binary '<<': no operator found which takes a right - hand operand of type 'const Kula'( or there is no acceptable conversion ) wyczytalem na stockoverflow że niby dołaczyc mam biblioteke string, ale nie pomogło. Prosze o pomoc. #include "stdafx.h" #include <iostream> #include <vector> #include <list> #include <algorithm> #include <iterator> #include <ctime> #include <cstdlib> #include <numeric> #include <iomanip> #include <functional> #include <string>
using namespace std;
struct Kula { public: int r; };
class Gen { private: int beg; int end; public: Gen() { beg = 10; end = 20; srand( time( NULL ) ); } Kula operator ()() { Kula tmp; tmp.r = beg +( rand() % end - beg + 1 ); return tmp; } };
int main() { vector < Kula > kulka( 10 ); generate( kulka.begin(), kulka.end(), Gen() ); copy( kulka.begin(), kulka.end(), ostream_iterator < Kula >( cout, " " ) ); getchar(); return 0; } |
|
akwes |
» 2015-04-13 10:17:45 Skąd kompilator ma wiedzieć jak wypisać Twój obiekt? Musisz przeładować operator << dla swojego obiektu Kula. |
|
« 1 » |