So I just started working with Objects and am now transition from using arrays to vectors, and to be honest I am completely lost. I need to create a program that can read information from a file containing:
Last name, First name, initial
Street Address
State Zip code City
Account Number(6 digit integer) Balance
so I my class has this information:
Class Bank_Account
{
Private:
-string name, address, state;
-int zip_code;
-float balance;
Public:
+ bool Open_file(ifstream&,int);
+ int Read (ifstream&, vector<>&);
+ another function
+ another function
+ another function
}
my int main() has a vector declared as
vector <Bank_Account> record;
anyways for my reading function I formatted it like this:
int Read (ifstream&, vector<>&)
{
vector<Bank_Account> BA;
while (!fin.eof())
{
Bank_Account BA;
BA.getname();
BA.getaddress();
BA.getstate();
BA.getzip_code();
BA.getbalance();
record.push_back(BA);
}
now I'm sure this is all a horrible mess because I am so confused and have been trying to fix it but then as I read I think I am doing it wrong and switch things around...can someone jst give me a rough sketch of what goes where and why so I can use it as a guideline to fix my horrible mess here? Or let me know what I've done wrong. I feel as if I am walking in the dark here. Thanks :)