本文介绍了任何人都可以帮助解决程序中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

#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'));
}


在函数`void start_menu()'':
一个''未声明(首先使用此功能)
(每个未声明的标识符对于出现在其中的每个功能仅报告一次.)


预期的init声明符,位于}}令牌之前
预期的`,''或`;''在''}''标记之前

''}''标记之前的预期声明

[edit]粘贴了以下作者贡献的错误消息[/edit]


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]

推荐答案

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...



while((choice != ''Q'') || (choice != ''q''));



代替



instead of

while((a.choice != ''Q'') || (a.choice != ''q''));


这篇关于任何人都可以帮助解决程序中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 10:13