printing to outfile?

I can't figure out why I can't print to the outfile. I'm getting errors in this area. On line 134 I've got std.print(out); if I remove 'out' then it compiles, but prints to console not the outfile. What am I missing?

Error 1 error C2660: 'BankAccount::print' : function does not take 1 arguments 142 1

2 IntelliSense: too many arguments in function call 142 15


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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>

using namespace std;

class BankAccount
{
private:
	int ActNum;
	string LastName;
	string FirstName;
	double balance;
public:
	BankAccount()
	{
		ActNum = 0;
		balance = 0.0;
	}
	BankAccount(int act, string first, string last, double bal)
	{
		ActNum = act;
		FirstName = first;
		LastName = last;
		balance = bal;
	}

	void setLastName(string last)
	{
		LastName = last;
	}

	int getActNum()
	{
		return ActNum;
	}

	string getFirstName()
	{
		return FirstName;
	}

	string getLastName()
	{
		return LastName;
	}

	double getbalance()
	{
		return balance;
	}

	void print()
	{
		cout<<fixed<<showpoint<<setprecision(2);
		cout<<"Account Number: "<<ActNum<<endl;
		cout<<"Name: "<<FirstName<<' '<<LastName<<endl;
		cout<<"Current Balance: $"<<balance<<endl;
	}
	
	void deposit(double money)
	{
		balance = balance + money;
	}

	void withdraw(double money)
	{
		if (money > balance)
		{
			cout<<"INSUFFICIENT FUNDS"<<endl;
		}
		else
		{
			balance = balance - money;
		}
	}
};

int main()
{

	BankAccount std;
	bool done = false;
	while(!done)
	{
		cout<<"****************************************"<<endl;
		cout<<"MAIN MENU"<<endl;
		cout<<"1. Create Bank Account from keyboard entry."<<endl;
		cout<<"2. Print Bank Account to console."<<endl;
		cout<<"3. Print Bank Account to output file."<<endl;
		cout<<"4. Make a deposit."<<endl;
		cout<<"5. Make a withdraw."<<endl;
		cout<<"6. Print current balance to console."<<endl;
		cout<<"7. Print full name to console."<<endl;
		cout<<"8. Exit."<<endl;
		int response;
		cin>>response;

		if(response == 1)
		{
			cout<<"Enter First Name: ";
			string first;
			cin>>first;
			cout<<"Enter Last Name: ";
			string last;
			cin>>last;
			cout<<"Enter Account number: ";
			int act;
			cin>>act;
			cout<<"Enter balance: ";
			double bal;
			cin>>bal;
			std = BankAccount(act, first, last, bal);
		}
		else if(response == 2)
		{
			std.print();
		}
		else if(response == 3)
		{
			string fileName;
			cout<<"Enter full path to output file: ";
			cin.sync();
			getline(cin, fileName);
			ofstream out;
			out.open(fileName, ios::app);
			if(!out)
			{
				cout<<"Bad file name or path."<<endl;
			}
			else
			{
				std.print(out);
			}
			out.close();
		}
		else if(response == 4)
		{
			double money = 0.0;
			cout<<"enter amount of deposit: ";
			cin>>money;
			std.deposit(money);
			cout<<"Here is your current balance: $";
			cout<<std.getbalance()<<endl;
		}
		else if(response == 5)
		{
			double money = 0.0;
			cout<<"enter the amount of withdraw: ";
			cin>>money;
			std.withdraw(money);
			cout<<"Here is your current balance: $";
			cout<<std.getbalance()<<endl;
		}
		else if(response == 6)
		{
			cout<<"Here is your current balance: $"<<std.getbalance()<<endl;
		}
		else if(response == 7)
		{
			cout<<std.getFirstName()<<' '<<std.getLastName()<<endl;
		}
		else if(response == 8)
		{
			done = true;
		}
		else
		{
			cout<<"No menu item corresponds to the number you entered."<<endl;
		}
	}


	return 0;
}

Your print() member function doesn't take any arguments. You will have to add the argument to your function.
I see. Got it now. Thank you
Topic archived. No new replies allowed.