I am suppose to use arrays where i read in data from a text file and i have to set these functions to it. any clues on how i would approach it.
my main concern is how to read data from a file using class while using arrays. i know how to do it in main function but i am confused about using it with class.
would i read it with a function in side the class? or inside main and pass it inside class (if this is even doable).
Please help..

thanks in advance.

#include<iostream>
#include<string>
using namespace std;
class AtmMachine{
public:
	void getAccountNumber();
	void setAccountNumber();
	void getAccountHolderName();
	void setAccountHolderName();
	void getCurrentBalance();
	void setCurrentBalance();
	void add2CurrentBalance();
	void subtractFromCurrentBalance();
	customerAccounts[500];
	actulCustomerNumber[];
private:
	string fName;
	string lName;
	int accountNum;
	int currentBalance;
	int pinNum;
};

int main()
{

}

Lines 14 and 15 need types. Line 15 needs an array size. The question is too vague. How to read from the file depends entirely on the makeup of the file. You also need to specify whether you need to write your own << and >> operators.

You'll want to research fstream for reading the files as well.

I know how to do it in main function but i am confused about using it with class.

Then whats the problem. just map that functionality into the function OR if you are unable to do that, then usually it means that your program structure is not good . You need to revisit the your program structure. As someone said earlier, you need use fstream (and ostream for writing) in your program.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.