Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include <iostream>
#include <string>

using namespace std;

void start_menu()
{
	do{
		char choice;
		cout << " VaruBanditen" <<       endl
			<< " ------------" <<    endl
			<< endl << " Varor:" << endl
			<< "   (1) S?ckpipa\t50kr\t (5)  Isglass\t\t 2kr" <<           endl
			<< "   (2) Potta\t10kr\t (6)  Fotboll\t\t15kr" <<                       endl
			<< "   (3) Fiskn?t\t25kr\t (7)  Skruvmejsel\t10kr"  <<         endl
			<< "   (4) Dunjacka\t95kr\t (8)  Toalettpapper\t 7kr" <<        endl
			<< endl << " Myntinkast:" << endl << " [A] 10kr  [B] 5kr  [C] 1kr"

			<< endl << " Kredit: " << start_menu().s_change() << "Kr" <<          endl

			<< endl << " [V] L?gg till/ta bort varor" << endl
			<< " [Q] Avsluta programmet" << endl << endl
			<< " -----------" << endl
			<< " Angel val: ";

		cin >> choice;
		a.do_choice(choice);
	}while((a.choice != 'Q') || (a.choice != 'q'));
}

In function `void start_menu()':
a' undeclared (first use this function)
(Each undeclared identifier is reported only once for each function it appears in.)


expected init-declarator before '}' token
expected `,' or `;' before '}' token

expected declaration before '}' token

[edit]pasted error messages from authors contribution below[/edit]
Posted
Updated 30-May-11 6:10am
v3
Comments
Kim Togo 29-May-11 7:43am    
What is the problem ?
Sergey Alexandrovich Kryukov 29-May-11 15:43pm    
The problem is style, of course. But what seems to be a problem, from your point of view?
--SA

Are you sure you wanted to do this:
void start_menu()
...
			<< endl << " Kredit: " << start_menu().s_change() << "Kr" <<          endl
...
Even if it compiled (which it shouldn't) it would cause an infinite loop...
 
Share this answer
 
((a.choice != 'Q') || (a.choice != 'q'))

will always be true as a.choice can only be either 'Q' or 'q'
I think you meant

((a.choice != 'Q') && (a.choice != 'q'))
 
Share this answer
 
v2
Comments
Legor 29-May-11 9:28am    
Wrong. This will not allways be true. It can be any character not just q. I think the loop should run until either'q' or 'Q' are pressed.
Manfred Rudolf Bihy 30-May-11 12:18pm    
Logic isn't one your strengths I presume. As Geoffrey stated the above expression is always true. His guess at what OP really meant is most likely right.
Geoffrey Moir 29-May-11 9:38am    
if a.choice == 'Q', then the first expression will be false and the second true, therefore true,
if a.choice == 'q', then the second expression will be false, and the first true, therefore true,
if a.choice == something else, then they will both be true, therefore true.

if a.choice == 'Q', then (false || true) == true! the logical OR should be a logical AND
Legor 31-May-11 5:05am    
Yes i was mistaken. Take my 5.
Geoffrey Moir 31-May-11 5:26am    
thanks Legor
use
while((choice != 'Q') || (choice != 'q'));


instead of
while((a.choice != 'Q') || (a.choice != 'q'));
 
Share this answer
 
Comments
Geoffrey Moir 29-May-11 21:33pm    
read reply #4
1. As OriginalGriff already indicated in Solution 2, fix this line:
C++
<< endl << " Kredit: " << start_menu().s_change() << "Kr" <<          endl


2. Fix this line:
a.do_choice(choice);
Neither 'a' nor 'do_choice(char) is declared anywhere. You need to declare symbols before you can use them.

E. g. you may declare the function at the top like this:
void do_choice(char);
and later, ommitting the 'a.' prefix, call it as
do_choice(choice);
Of course, you still have to define the function somewhere.

3. As indicated before (see solution 4), change this line:
}while((a.choice != 'Q') || (a.choice != 'q'));
to
}while((choice != 'Q') && (choice != 'q'));
 
Share this answer
 
v3
<code>not find error!!!</code>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900