裁判 [英] refs

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

问题描述

你好


在main.cpp中:

CWorld * gameWorld =新的CWorld; //我需要这个吗?

CSimpEngine * MyCSimpEngine =新的CSimpEngine;

CWorld * world = MyCSimpEngine-> OnGetWorld();


world-> Prepare(); //这里我得到以下错误

in simpengine.h:

class CSimpEngine //:public CEngine

{

私人:

CWorld * gameWorld;


public:

CWorld * OnGetWorld(){return gameWorld; }

}

在world.cpp中:

CWorld :: CWorld()

{

CTerrain * terrain =新CTerrain(256,0.5);

}


world.cpp:59:错误:`terrain''未声明(首先使用此功能)

为什么我会收到错误?在我理解OnGetWorld后初始化

CWorld哪个构造函数初始化地形?我错了吗?我需要

第一行main.cpp吗?

感谢和来自瑞士的问候

Michael

- -

我应该成为像我的邻居费德勒一样的网球No.1 ......好吧现在它已经太晚了: - /

Hello

In main.cpp:
CWorld* gameWorld = new CWorld; // do i need this?
CSimpEngine* MyCSimpEngine = new CSimpEngine;
CWorld *world = MyCSimpEngine->OnGetWorld();

world->Prepare(); //here i get the error below
in simpengine.h:
class CSimpEngine //: public CEngine
{
private:
CWorld *gameWorld;

public:
CWorld *OnGetWorld() { return gameWorld; }
}
in world.cpp:
CWorld::CWorld()
{
CTerrain* terrain = new CTerrain(256, 0.5);
}

world.cpp:59: error: ` terrain'' undeclared (first use this function)
Why do i get the error? After my understanding OnGetWorld initializes
CWorld which constructor initializes terrain? Am i wrong? Do i need the
first line of main.cpp?
THANKS and regards from Switzerland
Michael
---
I should have become a Tennis No.1 like my neighbor Federer...well now it''s
too late :-/

推荐答案

Michael Sgier写道:
Michael Sgier wrote:
在main.cpp中:
CWorld * gameWorld =新的CWorld; //我需要这个吗?


你在评论中提出的问题:你问我们还是你自己?

如果你想问我们,那我们就不会我知道。你发布了这么该死的

你的代码很少,没有办法告诉它几乎任何东西



CSimpEngine * MyCSimpEngine = new CSimpEngine;
CWorld * world = MyCSimpEngine-> OnGetWorld();

world-> Prepare(); //这里我得到的错误


为什么不说你得到什么错误,就在这里,你为什么要我们

去寻找它在下面?这是''world.cpp''的第59行吗?我不这么认为。
不这么认为。那么,你在下面得到的其他错误是什么?那个你想要讨论的是什么?

in simpengine.h:
class CSimpEngine //:public CEngine
{
私人:
CWorld * gameWorld;

公开:
CWorld * OnGetWorld(){return gameWorld; }
}


这应该与其余部分相关吗?

in world.cpp:
CWorld :: CWorld()
{
CTerrain * terrain =新CTerrain(256,0.5);
}

world.cpp:59:错误:`terrain''未声明(首先使用此功能)
为什么我会收到错误?


你确定你得到*那个*错误吗?我只能想到'CTerrain''

是未申报的,而不是地形。 ''terrain''声明实际上是

那个特定的声明,所以编译器不能抱怨你有

未声明''地形''如果你'只是声明它......

我的理解后OnGetWorld初始化
CWorld哪个构造函数初始化地形?


''terrain''是一个局部变量,存在于''CWorld''默认c-tor

执行期间。
$ b $我错了吗?


可能。也许。错了什么?

我需要
main.cpp的第一行吗?
In main.cpp:
CWorld* gameWorld = new CWorld; // do i need this?
The question you put in the comment: are you asking us or yourself?
If you''re trying to ask us, then we don''t know. You posted so damn
little of your code, there is no way to tell pretty much anything
from it.
CSimpEngine* MyCSimpEngine = new CSimpEngine;
CWorld *world = MyCSimpEngine->OnGetWorld();

world->Prepare(); //here i get the error below
Why don''t you say what error you get, right here, why do you want us
to go look for it "below"? Is that the line 59 of ''world.cpp''? I do
not think so. So, what other error you''re getting "below" that you
might be talking about?
in simpengine.h:
class CSimpEngine //: public CEngine
{
private:
CWorld *gameWorld;

public:
CWorld *OnGetWorld() { return gameWorld; }
}
Is this supposed to be relevant to the rest of it?
in world.cpp:
CWorld::CWorld()
{
CTerrain* terrain = new CTerrain(256, 0.5);
}

world.cpp:59: error: ` terrain'' undeclared (first use this function)
Why do i get the error?
Are you sure you''re getting *that* error? I can only think of ''CTerrain''
as being undeclared, not ''terrain''. ''terrain'' declaration is actually
that particular statement, so the compiler can''t complain that you have
not declared ''terrain'' yet if you''re just declaring it...
After my understanding OnGetWorld initializes
CWorld which constructor initializes terrain?
''terrain'' is a local variable that exists during ''CWorld'' default c-tor
execution.
Am i wrong?
Likely. Maybe. Wrong about what?
Do i need
the first line of main.cpp?




我不知道。你想用它做什么?


V



I don''t know. What are you trying to accomplish with it?

V




" Michael Sgier" < SG *** @ nospam.ch>在消息中写道

news:43 ********************** @ news.sunrise.ch ...

"Michael Sgier" <sg***@nospam.ch> wrote in message
news:43**********************@news.sunrise.ch...
你好

在main.cpp:
CWorld * gameWorld =新的CWorld; //我需要这个吗?


可能不是。可能足够的是:


CWorld gameWorld;


...除非有某些特定原因

你没说明为什么需要动态分配

你的对象。如果你决定继续使用''new'',

不要忘记删除这个对象完成

吧。

CSimpEngine * MyCSimpEngine = new CSimpEngine;


同样在这里。有什么理由你不能简单地使用


CSimpEngine MyCSimpEngine;


(做它这样,当执行离开范围时,对象将自动被销毁,其中定义了

$

CWorld * world = MyCSimpEngine - > OnGetWorld();
world-> Prepare(); //这里我得到以下错误

in simpengine.h:
class CSimpEngine //:public CEngine
{
私人:
CWorld * gameWorld ;

公开:
CWorld * OnGetWorld(){return gameWorld;在world.cpp中

CWorld :: CWorld()
{
CTerrain * terrain = new CTerrain(256,0.5);
}

world.cpp:59:错误:`terrain''未声明(首先使用此功能)
为什么我会收到错误?在我了解OnGetWorld之后初始化
CWorld


不在您发布的代码中。所有''OnGetWOrld()''函数

确实返回一个指向''CWorld''对象的指针。没有初始化

执行任何事情。

哪个构造函数初始化地形?


你的''OnGetWorld()''不会创建任何类型的''CWorld''对象

(或任何其他类型的对象)。所以没有''CWorld()''构造函数

被调用。

我错了吗?


是的。

我需要
第一行main.cpp吗?
Hello

In main.cpp:
CWorld* gameWorld = new CWorld; // do i need this?
Probably not. Probably sufficient is:

CWorld gameWorld;

... unless there''s some specific reason which
you didn''t state why need to dynamically allocate
your object. If you decide to stay with ''new'',
don''t forget to ''delete'' the object when done
with it.
CSimpEngine* MyCSimpEngine = new CSimpEngine;
Same here. Is there some reason you can''t simply
use:

CSimpEngine MyCSimpEngine;

(Doing it this way, the object will be automatically
destroyed when execution leaves the scope where it''s
defined)
CWorld *world = MyCSimpEngine->OnGetWorld();
world->Prepare(); //here i get the error below
in simpengine.h:
class CSimpEngine //: public CEngine
{
private:
CWorld *gameWorld;

public:
CWorld *OnGetWorld() { return gameWorld; }
}
in world.cpp:
CWorld::CWorld()
{
CTerrain* terrain = new CTerrain(256, 0.5);
}

world.cpp:59: error: ` terrain'' undeclared (first use this function)
Why do i get the error? After my understanding OnGetWorld initializes
CWorld
Not in the code you posted. All your ''OnGetWOrld()'' function
does is return a pointer to a ''CWorld'' object. No initialization
of anything is performed.
which constructor initializes terrain?
your ''OnGetWorld()'' does not create any type ''CWorld'' objects
(or any other type of object). So no ''CWorld()'' constructor
is called.
Am i wrong?
Yes.
Do i need the
first line of main.cpp?




取决于你希望你的程序做什么。


-Mike



Depends upon what you want your program to do.

-Mike


Michael Sgier写道:
Michael Sgier wrote:
你好

在main.cpp中:
CWorld * gameWorld =新的CWorld; //我需要这个吗?
CSimpEngine * MyCSimpEngine = new CSimpEngine;
CWorld * world = MyCSimpEngine-> OnGetWorld();

world-> Prepare(); //这里我得到以下错误

in simpengine.h:
class CSimpEngine //:public CEngine
{
私人:
CWorld * gameWorld ;

公开:
CWorld * OnGetWorld(){return gameWorld;在world.cpp中

CWorld :: CWorld()
{
CTerrain * terrain = new CTerrain(256,0.5);
}

world.cpp:59:错误:`terrain''未声明(首先使用此功能)
为什么我会收到错误?在我理解OnGetWorld之后初始化
CWorld哪个构造函数初始化地形?我错了吗?我需要
第一行main.cpp吗?
感谢瑞士的问候
迈克尔
Hello

In main.cpp:
CWorld* gameWorld = new CWorld; // do i need this?
CSimpEngine* MyCSimpEngine = new CSimpEngine;
CWorld *world = MyCSimpEngine->OnGetWorld();

world->Prepare(); //here i get the error below
in simpengine.h:
class CSimpEngine //: public CEngine
{
private:
CWorld *gameWorld;

public:
CWorld *OnGetWorld() { return gameWorld; }
}
in world.cpp:
CWorld::CWorld()
{
CTerrain* terrain = new CTerrain(256, 0.5);
}

world.cpp:59: error: ` terrain'' undeclared (first use this function)
Why do i get the error? After my understanding OnGetWorld initializes
CWorld which constructor initializes terrain? Am i wrong? Do i need the
first line of main.cpp?
THANKS and regards from Switzerland
Michael




我很害怕你又做了同样的事情。当你有编译器

错误时,请发布* ALL *代码。回答

您在所发布的代码中提出的任何一个问题都是不可能的。


您对OnGetWorld的理解不正确,但无论如何都是无关紧要的

,因为这是一个编译器错误。


完全猜测我会说你的问题是因为没有
包括正确的头文件,但当然我不能告诉因为

你没有发布所有代码。


请你,你已经发了好几次对于这个小组,你问好b / b
问题,但如果你想要问题,请在所有代码后回答。


john



I''m afraid you are doing the same thing again. When you have compiler
error please post *ALL* the code. It is quite impossible to answer
either of the questions you asked on the code you have posted.

Your understanding about OnGetWorld is incorrect, but irrelevent anyway
because this is a compiler error.

Taking a complete guess I would say the your problem is because of not
including the correct header files, but of course I cannot tell BECAUSE
YOU DIDN''T POST ALL THE CODE.

Please, you''ve posted several times to this group, you ask good
questions but if you want you questions answered post all the code.

john


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

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