Input to Array!

I'm having some problems with Input to an array from a file. I think that i need to make a new array for every instance of the loop but i can't figure out how.
Help is much appreciated!

Participator class
1
2
3
4
5
void Participator::read(ifstream &stream){
	getline(stream, name);
	getline(stream, address);
	stream >> paid;
}


ParticipatorRegister class
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
void ParticipatorRregister::readFromFile(){
	ifstream myFile;
	string fileName;
	cout << "enter a filename" << endl;
	cin >> fileName;
	myFile.open(fileName);
	if (myFile.is_open()){
		myFile >> nrOfParticipators;
		for (int i = 0; i < nrOfParticipators; i++){
			participators[i]->read(myFile);
		}
		myFile.close();
	}
	else{
		cout << "ERROR could not open file for instream" << endl;
	}
}


mainProgram class
1
2
3
void readFromFile(ParticipatorRregister *myArray){
	myArray->readFromFile();
}
Last edited on
Overloading Operator Example:

X& X::operator=(X rhs)
{
swap(rhs);
return *this;
}

Other examples and information at this link:

http://stackoverflow.com/questions/4421706/operator-overloading
Topic archived. No new replies allowed.