Classes code help

Ok, I am new to using classes, and am running into an issue already. I have created the class, and am in the process of adding data to the classes. I have added one piece of data, and now just want to see if I can get it to show in another function, but I am not sure why it is not showing. Can someone please help me with getting the data to show. Then, I will be able to work on adding the rest of the info.

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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
#include <iostream>
#include <cctype>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

//******************************Bill Class**************************
class bill {
private:
	string bCategory;  // bill category
	long account;  // account number
	float balance;  // bill balance
	string ddate;  // due date
	string bdate;  // bill date
public:
	bill();
	//~bill();

	bill(string, long, float, string, string);
	
	string getCategory()  //Get the category from user.
	{
		return bCategory; 
	}	

	void setCategory(string category) // Set the category.
	{
		bCategory = category;
	}

	long getAccount()
	{
		return account;
	}
	void setAccount(long acct)
	{
		account = acct;
	}
	short getBalance();
	void setBalance(float);
	string getDDate();
	void setDDate(string);
	string getBDate();
	void setBDate(string);

	void aBills();  //add bill
	void mBills();	// Modify Bill
	void dBills();	// Delete Bill
	void vBills();	// View Bill
};
//******************************Initialize Bill Class**********************************
bill::bill()
{
	bCategory = "";
	account = 0;
	balance = 0.00;
	ddate = "";
	bdate = "";

}
//******************************Initialize Bill Class**********************************
bill::bill(string category, long acct, float bal, string due, string issue)
{
	bCategory = category;
	account = acct;
	balance = bal;
	ddate = due;
	bdate = issue;

}
//******************************Bills Section******************************************
void bill::aBills()
{
	// Add Bills to the application.
	system("cls");
	cout << "This is the Add Bills screen.\n";

	char choice;
				
	do  // Runs question until a correct response is made.
	{		
		cout << "\n\nPlease select a category that matches the bill:  "
			<< "Medical (M), House (H), Credit (C):  ";
		cin >> choice;

		choice = toupper(choice);
		
		switch(choice) // Gives user a choice of the categories to choose from.
		{
			case 'M':	bCategory = "Medical";
						break;
			case 'H':	bCategory = "House";
						break;
			case 'C':	bCategory = "Credit";
						break;
			default	:	cout << "Incorrect Selection, please try again!\n\n";
						system("pause");
						break;
		}
	}while ((choice != 'M') && (choice != 'H') && (choice != 'C'));
	
	cout << "\n\nPlease insert the bill account #";
	cin >> account;

	setCategory(bCategory);
	setAccount(account);
	system("pause");
}

void bill::mBills()
{
	// Modify or change Bills within the application.
	system("cls");
	cout << "This is the Modify Bills screen.\n";
	system("pause");
}

void bill::dBills()
{
	// Delete Bills from application.
	system("cls");
	cout << "This is the Delete Bills screen.\n";
	system("pause");
}

void bill::vBills()
{
	// View all bills within the application.
	system("cls");
	cout << "This is the View Bills screen.\n\n";

	cout << getCategory();
	system("pause");
}

void menuBills(bill med)
{
	int choice;
	
	do
	{
	system("cls");
	cout << "Bill Menu \n\n";
	cout << "1.\tAdd Bills\n";
	cout << "2.\tModify Bills\n";
	cout << "3.\tDelete Bills\n";
	cout << "4.\tView Bills\n";
	cout << "5.\tReturn to main screen.\n";
	cout << "\n\n";

	cout << "Insert the number of where you want to go:  ";
	cin >> choice;
	cout << "\n";

	switch (choice)
	{
	case 1	:	med.aBills();
				break;
	case 2	:	med.mBills();
				break;
	case 3	:	med.dBills();
				break;
	case 4	:	med.vBills();
				break;
	case 5	:	break;
	default	:	cout << "Please press a number corresponding to the menu.\n\n";
				system ("pause");
				break;
	}
	}while (choice != 5);
}
//******************************Paycheck Section**************************************
void aPaycheck()
{
	system("cls");
	cout << "This is the Add Paycheck screen.\n";
	system("pause");
}

void mPaycheck()
{
	system("cls");
	cout << "This is the Modify Paycheck screen.\n";
	system("pause");
}

void dPaycheck()
{
	system("cls");
	cout << "This is the Delete Paycheck screen.\n";
	system("pause");
}

void vPaycheck()
{
	system("cls");
	cout << "This is the View Paycheck screen.\n";
	system("pause");
}
void menuPayCheck()
{
	int choice;
	do
	{
	system("cls");
	cout << "Paycheck Menu \n\n";
	cout << "1.\tAdd Pay\n";
	cout << "2.\tModify Pay\n";
	cout << "3.\tDelete Pay\n";
	cout << "4.\tView Pay Info\n";
	cout << "5.\tExit\n";
	cout << "\n\n";

	cout << "Insert the number of where you want to go:  ";
	cin >> choice;
	cout << "\n";

	switch (choice)
	{
	case 1	:	aPaycheck();
				break;
	case 2	:	mPaycheck();
				break;
	case 3	:	dPaycheck();
				break;
	case 4	:	vPaycheck();
				break;
	case 5	:	break;
	default	:	cout << "Please press a number corresponding to the menu.\n\n";
				system ("pause");
				break;
	}
	}while (choice != 5);
}
//******************************View Bills Section************************************
void viewBills(bill med)
{
	system("cls");
	cout << "This is the View Bills screen.\n";

	//cout << med.getCategory();
	system("pause");
}
//******************************Pay Bills Section*************************************
void pBills()
{
	system("cls");
	cout << "This is the Pay Bills screen.\n";
	system("pause");
}

//******************************Main Section******************************************
void menuStart(bill med)
{
	int choice;

	do
	{
	system("cls");
	cout << "Start Menu \n\n";
	cout << "1.\tBills\n";
	cout << "2.\tPaycheck\n";
	cout << "3.\tView Bills\n";
	cout << "4.\tPay Bills\n";
	cout << "5.\tEXIT\n";
	cout << "\n\n";

	cout << "Insert the number of where you want to go:  ";
	cin >> choice;
	cout << "\n";

	switch (choice)
	{
	case 1	:	menuBills(med);
				break;
	case 2	:	menuPayCheck();
				break;
	case 3	:	viewBills(med);
				break;
	case 4	:	pBills();
				break;
	case 5	:	system("cls");
				cout << "Thanks for using my program!!";
				break;
	default	:	cout << "Please press a number corresponding to the menu.\n\n";
				system ("pause");
				break;
	}
	} while (choice != 5);
	
}
int main()
{
	bill med;

	// Introduction Screen

	cout << "Welcome to my Bill Organizer program.  This program is designed to take an entry of bills, \n"
		 << "and an entry of a pay check, and assist you with keeping track of the bills, as well as assist\n"
		 << "you on paying your bills by suggesting a payment amount.\n\n" << endl;

	system("pause");

	menuStart(med);
	return 0;
}


FYI - This is only the relevant code. There is more for this that I have not added. Please assist on getting this to compile and show, learning as I go.

Error #1: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)

Error #2: error C2679: binary '<<' : no operator found which takes a right-hand operand of type 'std::string' (or there is no acceptable conversion)


Last edited on
http://www.eelis.net/iso-c++/testcase.xhtml (6)
foo.cpp: In function ‘void menuStart(bill)’:
foo.cpp:169:24: error: ‘menuPayCheck’ was not declared in this scope
foo.cpp:173:18: error: ‘pBills’ was not declared in this scope

Also, note that the error messages include the line number.
Solution ended up being to add the #include <string> header. After adding this, the code compiled and worked like a charm.
Topic archived. No new replies allowed.