桂猜游戏 [英] Gui guessing game

查看:89
本文介绍了桂猜游戏的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的任务.

  让用户知道猜测是否太低,太高或正确的数字.  用户一直在猜测,直到正确理解为止.

Here is my assignment.

Write a Windows application that randomly generates a number from 0 through 100.  Prompt the user to guess the number.  Let the user know if the guess is too low, too high, or is the correct number.  Give the user another chance to guess the number.  The user keeps guessing until he gets it correctly.

I keep getting this error in my code.

1> h:\ documents and settings \ calvin \ mydocuments \ Visual Studio 2005 \ projects \ ilab06b \ ilab06b \ Form1.h(76):错误C3845:'ilab06b :: Form1 :: number':仅静态数据成员可以在ref类或值类型内部初始化

1>h:\documents and settings\calvin\my documents\visual studio 2005\projects\ilab06b\ilab06b\Form1.h(76) : error C3845: 'ilab06b::Form1::number': only static data members can be initialized inside a ref class or value type

 

这是代码,谢谢

 

#pragma

 

endregion

随机数=

Random(); //这是声明的数字;我们的随机器

new Random(); // This is declaring number; our randomizer

int

 

rn; //这是在声明rn;我们的随机数

rn; // This is declaring rn; our randomized number

int

 

gn; //这表示gn;我们的猜测数字

gn; // This is declaring gn; our guessed number

 

私有 :System :: Void Form1_Load(System :: Object ^发件人,System :: EventArgs ^ e){

private: System::Void Form1_Load(System::Object^ sender, System::EventArgs^ e) {

rn = number.Next(1,100);

rn = number.Next(1,100);

 

}

};

}

推荐答案

1> h:\ documents and settings \ calvin \ mydocuments \ visual studio 2005 \ projects \ ilab06b \ ilab06b \ Form1.h(76):错误C3845:'ilab06b :: Form1 :: number':仅静态数据成员可以在ref类或值类型内初始化
1>h:\documents and settings\calvin\my documents\visual studio 2005\projects\ilab06b\ilab06b\Form1.h(76) : error C3845: 'ilab06b::Form1::number': only static data members can be initialized inside a ref class or value type

在Form1构造函数中初始化数字",而不是在类定义的主体中初始化.
 

Initialize 'number' in the Form1 constructor, not in the body of the class definition.
 


这篇关于桂猜游戏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆