Jan 23, 2011 at 9:00pm UTC
when attempting to compile my program i am getting a error that says
error C2065: 'bankfile' : undeclared identifier in int main, can someone please help here
#include<iostream>
#include<fstream>
#include<cstring>
using namespace std;
//global declarations
const int NAMESIZE = 11;
typedef char fname_t[NAMESIZE];
typedef char lname_t[NAMESIZE];
typedef int acctid_t;
typedef double balance_t;
typedef fstream bankfile_t;
const int FILESIZE = 11;
typedef char filename_t[FILESIZE];
class bank
{
private:
fname_t fname;
lname_t lname;
acctid_t acctid;
balance_t balance;
filename_t filename;
bankfile_t bankfile;
public:
bank();
void Initialize(fstream&bankfile);
void Inputandwrite(fstream&bfile);
void Finalize(fstream&bfile);
};//bank
//implentations of the bank methods
bank::bank()
{
strcpy(fname," ");
acctid = -1;
}//bank
void bank::Initialize(fstream&bankfile)
{
cout<<"Enter name of the file to be created: ";
cin >> filename;
bankfile.open(filename,ios::out);
if(bankfile.fail())
{
cout<< "Error on opening the file"
<<endl;
}}//Initialize
void bank::Inputandwrite(fstream&bfile)
{
cout << "Enter full name( or QUIT to quit):";
cin>> fname >> lname;
while(strcmp(fname,"QUIT")!=0)
{
cout << "Enter acct id: ";
cin>> acctid;
cout<< "Enter account balance: ";
cin >> balance;
bfile<< fname << endl;
bfile<< lname << endl;
bfile<< acctid << endl;
bfile<< balance<< endl;
cout<< " Enter Full Name(or QUIT): ";
cin>> fname >> lname;
}}//Inputandwrite
void bank::Finalize(fstream&bfile)
{
bfile.close();
cout << "Full closed-terminating"
<<endl;
}
int main()
{
bank bankone;
bankone.Initialize(filename);
bankone.Inputandwrite(bankfile);
bankone.Finalize(bankfile);
return 0;
}
Jan 23, 2011 at 9:14pm UTC
bankfile is a member of bank, so call it with bankone.bankfile
.
Last edited on Jan 23, 2011 at 9:14pm UTC