dimanche 31 mai 2015

ifstream attempting reference to a deleted function

I'm writing a code for a virtual tournament. The problem is that team class has an ifstream object, I understand that stream objects do not have copy constructors, therefore i converted playing8 from vector of team objects to pointer to object, So that team objects will not be copied.But now i get this error Error 16 error C2280: 'std::basic_ifstream>::basic_ifstream(const std::basic_ifstream> &)' : attempting to reference a deleted function c:\program files (x86)\microsoft visual studio 12.0\vc\include\xmemory0 592 1 Assignment3

How do i resolve this without removing ifstream object from team class? heres code for tournament.h

#include "team.h"

class Tournament
{
std::ofstream out_file;
std::ifstream in_file;
std::vector<team> teams;
std::vector<team*> playing8;
public:
void schedule();
void schedule2();
void tfinal();
void selectPlaying8();
void rankTeams();
void match(int,int);
Tournament();
~Tournament();
};

code for tournament constructor

Tournament::Tournament()
{
srand(time(NULL));
in_file.open("team_list.txt");
string input;
int noteam=0;
while (getline(in_file, input)){
    noteam++;
}
in_file.close();
for (int i = 0; i < noteam;i++){
    string x=to_string(i)+".csv";
    team temp(x);
    temp.set_teamform((6 + rand() % 5) / 10.0);
    teams.push_back(temp);
}
}

code for select playing 8;

void Tournament::selectPlaying8(){
for (int i = 0; i < 7; i++){
    playing8.push_back(&teams[i]);
    playing8[i]->set_playing();
}

attributes of team class

#include <string>
#include <vector>
#include <fstream>
#include <iostream>
#include "Player.h"

class team 
{
private:
std::ifstream in_file;
std::vector<Player> playing11;
std::string teamname;
std::vector<Player> player;
bool playing;
float matchperformance;
float teamform;
float team_rank_score;
};

Im using visual studio express 2013

Aucun commentaire:

Enregistrer un commentaire