This is my homework, no i don't need it done, i only need a tip on why my overloaded operator and iterator function in public is just giving me the same(too many parameter) error. This part of the program is supposed to print all the objects in the already setup lists in the bank class... I only need a hint, not the solution(unless you are willing to do that, but i wouldn't be learning anything). Thanks.
Code:
#include <iostream>
#include <list>
#include <fstream>
#include <string>
using namespace std;
class account
{
public:
account(): n(0), d(0.0)
{}
account(int acct, string acctname, float abalance) : n(acct), str1(acctname), d(abalance)
{}
friend ostream& operator << (ostream& os, account& p)
{
cout << "Printing original data in the account: " << endl;
for(Act = accountlist.begin(); Act != accountlist.end(); Act++)
{
os << *Act << " ";
}
cout << endl;
}
private:
int n;
string str1;
float d;
list<account>::iterator Act;
};
class transaction
{
public:
transaction(): n1(0), d1(0.0)
{}
transaction(int acctnm, string lttr, float tamount) : n1(acctnm), c(lttr), d1(tamount)
{}
friend ostream& operator << (ostream os, transaction& q )
{
cout << "Printing original transaction data: " << endl;
for(Trn = transactionlist.begin(); Trn != transactionlist.end(); Act++)
{
os << *Trn << ' ';
}
cout << endl;
}
private:
int n1;
string c;
float d1;
list<transaction>::iterator Trn;
};
class bank
{
public:
void openaccounts()
{
int n;
string str1;
float d;
account *p;
ifstream datafile("Myaccounts.txt");
{
while(!datafile.eof())
{
datafile >> n >> str1 >> d;
p=new account(n, str1, d);
accountlist.push_back(*p);
}
}
}
void opentransactions()
{
int n1;
string c;
float d1;
transaction *q;
ifstream datafile("Mytransactions.txt");
{
while(!datafile.eof())
{
datafile >> n1 >> c >> d1;
q=new transaction(n1, c, d1);
transactionlist.push_back(*q);
}
}
}
private:
list<account>accountlist;
list<transaction>transactionlist;
};
int main()
{
bank business;
business.openaccounts();
business.opentransactions();
return 0;
}
THANKS.