making an ATM Program in C++ "Help"
Statement of problem
I cant get this program to work right. I keep getting this error message.
(63) : error C2296: '+' : illegal, left operand has type 'float (__thiscall userInfo::*)(void)'
Ive tried several diffferent ways to run the account to write to file but it doesnt seem to work. I got the Password and ID to work ok but I just cant seem to get the rest. any suggestions?
this is the Main program.
# include <iostream>
# include <string>
# include <fstream>
# include "final2.h"
using namespace std;
int main ()
{
userInfo userId;
string userID ="";
string userP ="";
string ID,testId, testPassword;
string password;
char choice =' ';
float Dep=0.00;
float with=0.00;
float bal=0.00;
string err ="**** ERROR ****";
ofstream outFile;
ifstream inFile;
inFile.open("user.txt", ios::in);
if (inFile.is_open())
{
testId=userId.getID();
system("cls");
testPassword = userId.getP();
system("cls");
}
while ( !inFile.eof())
{
inFile >> ID;
inFile >> password;
if ((ID==testId) && (password ==testPassword))
{
cout << "**** Welcome " << userID << " ****" << endl;
cout << endl;
cout << "1 for Deposit" << endl;
cout << "2 for Withdrawl. " << endl;
cout << "3 for Balance." << endl;
cout << "4 for exit." << endl;
cin >> choice;
system("cls");
}
else
{
cout << err << endl;
return 0;
}
if ( choice = '1' )
{
outFile.is_open();
cout << "**** DEPOSIT ****" << endl;
cout << endl;
cout << "Enter the amount of deposit to savings account: ";
cin >> Dep;
userId.updateA();
}
else
if ( choice ='2')
{
cout << "**** WITHDRAWL ****" << endl;
cout << endl;
cout << "Enter the amount of the withdrawl from savings account: $";
cin >> with;
}
else
if ( choice ='3')
{
inFile.is_open();
bal = userId.getA();
cout << "**** BALANCE ****" << endl;
cout << endl;
cout << "Your savings balance is $" << bal << endl;
}
else
if ( choice ='4' )
{
cout << "**** EXIT ****" << endl;
cout << endl;
return 0;
}
else
{
cout << err << endl;
return 0;
}
inFile.close();
return 0;
}
return 0;
}
and this is the Class or Header file
# include <fstream>
# include <string>
using namespace std;
class userInfo
{
public:
userInfo();
void readFile (ifstream &);
float writeFile (ofstream &);
string getID();
string getP();
float getA();
float updateA();
private:
string ID;
string Pass;
float Acc;
};
userInfo::userInfo()
{
ID = "";
Pass = "";
Acc = 0.00;
// float newbal=0.00;
// float update=0.00;
}
void userInfo::readFile( ifstream &inF)
{
inF >> ID;
inF.ignore(1);
inF >> Pass;
inF.ignore(2);
inF >> Acc;
inF.ignore(3);
}
string userInfo::getID()
{
cout <<"enter ID: ";
cin >> ID;
return ID;
}
string userInfo::getP()
{
cout << "Enter Password: ";
cin >> Pass;
return Pass;
}
float userInfo::getA()
{
cout << "Your Account balance is $" << Acc << endl;
return Acc;
}
float userInfo::writeFile(ofstream &outF)
{
float newbal = 0.00;
//update = updateA;
outF.is_open();
newbal=(updateA + Acc);
outF << newbal;
return Acc;
outF.close();
}
and here is the Text file
Ghost IG1234 100.00