Tilted Forum Project Discussion Community  

Go Back   Tilted Forum Project Discussion Community > Interests > Tilted Technology


 
 
LinkBack Thread Tools
Old 05-26-2003, 07:57 PM   #1 (permalink)
Upright
 
Location: Chicago, Ill
Any C++ programmers in the house??/

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.

Last edited by cheerios; 05-27-2003 at 07:51 AM..
johnyto is offline  
Old 05-27-2003, 08:02 AM   #2 (permalink)
Banned
 
Location: 'bout 2 feet from my iMac
I fixed it so your intenting shows
the tags are [code] and [/ code] btw w/o the space.

as for the errors, I dunno...??? I'll pull out a book and look later, though
cheerios is offline  
Old 05-27-2003, 09:18 AM   #3 (permalink)
Upright
 
Location: Chicago, Ill
thanks, i will keep that in my for the next time. Thanks.
johnyto is offline  
Old 05-27-2003, 08:28 PM   #4 (permalink)
Tilted
 
Location: Ontario, Canada
I'm pretty new to C++ (only one semester under my belt right now)... however, just curious, what are you '#include'ing? From what I can tell, that may be the problem, as it is used 4 times, but nothing is declared after. I'm thinking you're missing:
#include <iostream>
#include <string>
#include <fstream>
#include <list>

Try that out and lemme know what happens!

Edit: My bad, the vbCode of this website blanks out the template declarations... weird Kinda figured you didn't forget them anyways
__________________
" Can't keep my eyes from the circling skies, Tongue-tied and twisted just an earth-bound misfit, I "

Last edited by Nooze2k; 05-27-2003 at 08:30 PM..
Nooze2k is offline  
 

Tags
house or, programmers


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -8. The time now is 03:06 PM.

Tilted Forum Project

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Search Engine Optimization by vBSEO 3.6.0 PL2
© 2002-2012 Tilted Forum Project

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76