So, I'm trying to access a section of a data file through an array used by another member function but I'm not sure how. I created a member function that reads the data(from the file) in arrays, and I want to access a certain array(ba[i]) in 3 different member functions without altering the code.
void ATM :: ReadData(){
    ifstream atmdat("atmdata.txt",ios::in);
    int i=0;
    while (!atmdat.eof()){
        atmdat>>a[i]>>ba[i];
        i++;
    }
    nc=i;
}
I tried just using the array in the member function. But, I'm not sure how to include the variable i without constantly repeating the function unwarranted.
This is one of the member functions.
After this is compiled, I'm expecting the function to use the ba[i] array of data to do the calculations for one customer.
void ATM::Withdraw()
{
    cout<<"How much would you like to withdraw?"<<endl;
    double w;
    cin>>w;
    ba[i]-=w;
    cout<<"Balance:$"<<ba[i]<<endl;
}
 
    