How to do an array of objects? I am trying but I am not succeeding, it returns me an error:
line 26 [Error] no match for 'operator []' (operand types are 'Time' and 'int')
Code:
#include <iostream>
#include <cstdlib>
#include <fstream>
#include <string>
#include "Time.h"
using namespace std;
int apaga_espaco(ifstream &tab, Time t)
{
string nome="gremio";
int saldo=0;
int vit=1,i;
string s;
char N;
while (tab.good())
{
i++;
getline(tab, s);
s.erase(0,29);
N=s.find(':');
s.erase(0,N+6);
return 0;
t[i].set_name(nome);
}
}
int main()
{
Time *t;
t=new Time[20];
ifstream tabe;
char N;
string s;
tabe.open("Tabela.txt", ios::in);
if (!tabe.is_open())
{
cout << "Arquivo nao encontrado, erro fatal!";
exit(1);
}
apaga_espaco(tabe,*t);
}