Getting only 1 long error

Hey all.

I am trying to start my c++ final and am running into a bit of trouble already. I have tried to get just the cout statement for each case to display but am not having any luck. Any feedback is welcomed.

**as i said, this is just the beginning**

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
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;


void displayMenu();

/*class account{

public:
	int act_num,
		withdrawls,
		deposits;

	string name;
	
	double rate,
		   fee;

}*/

void displayMenu()
{

	cout<<"Please input which selection you would like"<<endl;
	cout<<"-------------------------------------------"<<endl;
	cout<<"1. Savings Account Deposit                 "<<endl;
	cout<<"2. Checking Account Deposit                "<<endl;
	cout<<"3. Savings Account Withdrawl               "<<endl;
	cout<<"4. Checking Account Withdrawl              "<<endl;
	cout<<"5. Update and Display Account Statistics   "<<endl;
	cout<<"6. Exit                                    "<<endl;
	

}

int main()
{
	int choice;
	
	do
	{
		displayMenu();
		
		switch(choice)
		{
			case 1: cout<<"Your savings account has a balance of $"<<endl;
				    //cout<<savings.getbalance<<endl;
					//cout<<"How much would you like to deposit?"<<endl;
					//cin>>savings.deposit<<endl;
					break;
			case 2: cout<<"Your checking account has a balance of $"<<endl;
					//cout<<checking.getbalance<<endl;
					//cout<<"How much would you like to deposit?"<<endl;
					//cin>>checking.deposit<<endl;
					break;
			case 3: cout<<"Your savings account has a balance of $"<<endl;
				    //cout<<savings.getbalance<<endl;
					//cout<<"How much would you like to withdraw?"<<endl;
					//cin>>savings.withdraw>>endl;
					break;
			case 4: cout<<"Your checking account has a balance of $"<<endl;
				    //cout<<savings.getbalance<<endl;
					//cout<<"How much would you like to withdraw?"<<endl;
					//cin>>checking.withdraw>>endl;
					break;
			case 5: cout<<"Your checking account currently has $"<<endl;
					//cout<<getBalance.checking<<endl;
					//cout<<"Your savings account currently has $"<<endl;
					//cout<<getBalance.savings<<endl;
					break;
		}
		cin>>choice>>endl;
	}
	while(choice <= 5);
	return 0;
}


my error:
1>i:\computer science 2\practice\structures_again\structures_again\source1.cpp(74): error C2678: binary '>>' : no operator found which takes a left-hand operand of type 'std::basic_istream<_Elem,_Traits>' (or there is no acceptable conversion)
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream(1053): could be 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream(1060): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,signed char &)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\istream(1067): or 'std::basic_istream<_Elem,_Traits> &std::operator >><std::char_traits<char>>(std::basic_istream<_Elem,_Traits> &&,unsigned char *)'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1>


there is alot more but it will not fit.
Last edited on
Line 75, you are trying to read from cin into endl? Get rid of that; it doesn't make sense and is probably the source of your errors.
upon deleting line 75, it compiles with errors and then does this:

[IMG] http://i723.photobucket.com/albums/ww231/noradat/error.jpg [/IMG]

with this as the errors:

 1>i:\computer science 2\practice\structures_again\structures_again\source1.cpp(47): warning C4700: uninitialized local variable 'choice' used
1>Link:
1>  structures_again.vcxproj -> I:\Computer Science 2\Practice\structures_again\Debug\structures_again.exe
1>FinalizeBuildStatus:javascript:editbox1.editSend()
1>  Deleting file "Debug\structures_again.unsuccessfulbuild".
1>  Touching "Debug\structures_again.lastbuildstate".
1>
1>Build succeeded.
1>
1>Time Elapsed 00:00:04.19
========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ========== 
I would move 75 to 46, or right after you print the display menu.

It should look like: cin >> choice; not cin >> choice >> endl;

I would also make int choice = 0; not int choice;

lets see how many bugs that cleans up.
moving the cin line (line75) to line 46 did not change anything.

however, initializing choice to 0 was what fixed it. I dont really like that i have to initialize the variable to 0. seems like "pass by value" is being applied when choice changes from 0 (the initial value) to, lets say, menu choice 2.

I hope that makes sense. If it doesn't, i thank you for your help
Topic archived. No new replies allowed.