Panel użytkownika
Nazwa użytkownika:
Hasło:
Nie masz jeszcze konta?

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
Autor Wiadomość
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.

C/C++
#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()
{
    //1
    vector < Kula > kulka( 10 );
    //2
    generate( kulka.begin(), kulka.end(), Gen() );
    copy( kulka.begin(), kulka.end(), ostream_iterator < Kula >( cout, " " ) );
   
    getchar();
    return 0;
}
P-130770
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.
P-130772
« 1 »
  Strona 1 z 1