Hi guys! I want some help with my class here! I created a class that takes an input file with numbers (.dat or .txt)! The problem is that i want to create a seperate member function which will return the number of the elements of my function to use that number for another class!
Hope u can help me and thanx anyway :)
bool read = true; // loop control, as long as read is true the loop continues to read the numbers
while (read) // loop until we run out of file.
{
f >> n; // read a number. It might fail, but
if (!f.eof()) // we can test to see if it has reached past end of file
{
cout << n << endl; // debugging
countNumbers++;
}
else // Done. Terminate the loop, and close the file.
{
read = false;
f.close(); // dont forget to do this!
}
}
cout << n << endl; // so the code dont miss the last number
countNumbers++;
cout<<"The number of numbers is:\n"<<countNumbers<<endl;