C++ 未在此范围问题中声明
我正在查看并理解其他人的代码。。。代码在他的电脑里工作,但是当我试图在我的电脑里编辑它时,它似乎不起作用。库文件都连接正确C++ 未在此范围问题中声明,c++,C++,我正在查看并理解其他人的代码。。。代码在他的电脑里工作,但是当我试图在我的电脑里编辑它时,它似乎不起作用。库文件都连接正确 #include "play.h" #include "Lib110ct/Lib110ct.h" #include <ctime> int main(int argc, char** argv) { Win110ct win; Turtle * t = win.getTurtle(); win.hideTurtle(); const int NumOfBoo
#include "play.h"
#include "Lib110ct/Lib110ct.h"
#include <ctime>
int main(int argc, char** argv)
{
Win110ct win;
Turtle * t = win.getTurtle();
win.hideTurtle();
const int NumOfBook = 7;
Player You(512,384);
Book B[NumOfBook];
int pts = 0;
char in;
time_t ti;
while (in != 'x')
{
for (int i = 0; i<NumOfBook; i++)
{
if (A[i].isReadBy(You))
{
B[i].setPosition(rand() % 1024 + 1,rand() % 768 + 1);
pts++;
}
B[i].move();
B[i].draw(t);
}
You.draw(t);
win << "Points: " << pts << "\n";
win.render();
win.setPosition(-1,-1);
in = win.getchar();
win.clearBack();
win.clear();
win.setPosition(0,0);
if (in == 'w')
You.moveRelative(0,-50);
else if (in == 's')
You.moveRelative(0,50);
else if (in == 'a')
You.moveRelative(-50,0);
else if (in == 'd')
You.moveRelative(50,0);
}
return 0;
}
#包括“play.h”
#包括“Lib110ct/Lib110ct.h”
#包括
int main(int argc,字符**argv)
{
Win110ct win;
海龟*t=win.getTurtle();
win.hideTurtle();
常量int numobook=7;
玩家你(512384);
B册[NumOfBook];
int-pts=0;
炭素;
时间;
while(in!=“x”)
{
对于(int i=0;i您正在尝试使用“Book”类型的数组,这可能是您打算定义的类:
Book B[NumOfBook];
但是,您没有在上面发布的代码中或在Dropbox中输入的代码中定义这一点
为Book类添加一个要播放.h的定义,或者创建一个新的头文件,可能称为Book.h,使用该定义,然后#在您的cpp文件中包含“Book.h”。您的Book类将需要方法来设置位置、移动和绘制。您似乎缺少头文件“Book.h”那么,应该定义的Book
类型在哪里?在Lib110ct.h中?关于#include
,您是否有错误?这远远不是一个问题,这些是我得到的错误..我还将代码文件放在dropbox链接中,以便您可以查看…哪个文件有#include“Book.h”它不包含在你粘贴的文件中。抱歉,但是我认为我们不能教你这里的C++编程基础。如果你自己动手,我们也许可以解释你哪里出了问题。
Book B[NumOfBook];