- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我来找你是为了解决一个涉及多个不同文件的问题。我不确定为什么会收到标题中指定的错误。让我把文件放在下面,然后从那里开始。
虚拟客户端.cpp
#include "Gameboard.h" //for Gameboard
#include "Location.h" //for function prototypes
#include "zList.h" //for Zombies
#include <iostream> //for input/output stream
using namespace std;
void main()
{
srand(123456789);
Gameboard myGB;
myGB = Gameboard();
ZombieListClass();
ZombieRec zombieList[MAX_ZOMBIES];
PopulateZombies(zombieList[MAX_ZOMBIES]); // this throws the error here of "Error: identifier "PopulateZombies" is undefined"
}
zList.h
#ifndef ZLIST_H
#define ZLIST_H
#include "Location.h" // for list record
#include "ZombieRec.h"
#include "Gameboard.h"
class ZombieListClass
{
public:
ZombieListClass(); //default constructor
void PopulateZombies(ZombieRec zombieList[]);
bool IsInBounds(int row, int col);
private:
ZombieRec list[MAX_ZOMBIES]; //stores the items in the list
int length; //# of values currently in the list
int currPos; //position of current element
int strength; // health and attack units of a zombie
};
#endif
zList.cpp
#include "zList.h"
ZombieListClass::ZombieListClass() //default constructor
{
length = 0;
currPos = 0;
strength = 5;
LocationRec zombieLoc;
}
void ZombieListClass::PopulateZombies(ZombieRec zombieList[])
{
int row, col;
for (int i = 0; i < MAX_ZOMBIES; i++)
{
row = rand() % MAX_ROW + 1;
col = rand() % MAX_COL + 1;
while (!IsInBounds(row, col))
{
row = rand() % MAX_ROW + 1;
col = rand() % MAX_COL + 1;
}
zombieList[i].currLoc.row = row;
zombieList[i].currLoc.col = col;
}
}
bool ZombieListClass::IsInBounds(int row, int col)
{
if (row == 0 || row == MAX_ROW + 1 || col == 0 || col == MAX_COL + 1)
{
return false;
}
else
{
return true;
}
}
游戏板.h
#ifndef GAMEBOARD_H
#define GAMEBOARD_H
#include "Location.h"
#include "ZombieRec.h"
#include "zList.h"
const int MAX_ROW = 3; // total number of rows in the board
const int MAX_COL = 3; // total number of cols in the board
class Gameboard
{
public:
Gameboard();
private:
int boardSizeArr[MAX_ROW + 2][MAX_COL + 2];
}; // end Gameboard
#endif
最后,Gameboard.cpp
#include "Gameboard.h"
Gameboard::Gameboard()
{
// Declares a board with a boundary along the outside
boardSizeArr[MAX_ROW + 2][MAX_COL + 2];
}
我不想被人灌输,也不想有人为我解决我的问题,我想弄清楚我做错了什么,这样我的项目的其余部分就不会像以前那样坎坷一直以来。
回顾我的错误,“identifer “PopulateZombies” is undefined”,我无法想象这是为什么。这可能与我做事的范围有关吗?如果我遗漏了任何代码(我没有把所有东西都放在那里,但我认为我有所有相关的东西)请告诉我,只要这需要我就可以来回交谈。
提前感谢所有试图提供帮助的人:)
-安东尼
最佳答案
一般情况下,您使用变量调用函数,而不是在类中定义时直接调用它:
ZombieListClass zombieList=new ZombieListClass(); // add a variable here
ZombieRec zombieList[MAX_ZOMBIES];
zombieList.PopulateZombies(zombieList[MAX_ZOMBIES]); // See the difference?
关于C++ ~ 在客户端调用函数给出错误 : "identifier ____ is undefined",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26205734/
我在 swift 中创建了一个自定义类来管理我正在制作的游戏的主菜单我将它链接到 SKScene 文件并尝试创建一个常量来访问该变量但我得到了这个错误:无法使用实例成员'属性初始值设定项中的 chil
我目前正在使用 Chrome 控制台对 Greasemonkey 脚本进行一些调试。 我从控制台运行 var opp = document.querySelectorAll('a[class="F-r
我仍然是 PHP 和 MySQL 的新手,但愿意学习,经过三天的修修补补,现在我需要帮助。 首先,为了帮助您了解我的数据库结构,我有一个名为“o70vm_invoices_items”的 MySQL
我正试图在 C 中创建一个可以接受大多数原始类型的类型。我是 C 的新手,不太了解结构。我的错误发生在第 10 行(main.c),如果删除第 10 行(也是 main.c),它也会发生在第 11 行
这个问题在这里已经有了答案: My code signals the error "application: not a procedure" or "call to non procedure"
我目前正在从 this tutorial 学习 Java ,虽然术语有时让我感到困惑(实际上是本章),但我足以弄清楚代码为何有效。但在这种情况下,情况并非如此,这不是我的代码不起作用,而是教程的代码不
我有来自“ScoreHistory.swift”的以下变量: // ScoreHistory.swift var datePlayed: NSDate var totalScore: Int var
我在一个单独的类(称为 ExternalClass)中设置了一个方法,该方法需要接受两个参数。 -(void) openImage:(NSDictionary *)payload InApp:(UIA
这个问题已经有答案了: How to access the correct `this` inside a callback (15 个回答) 已关闭 5 年前。 作为练习,我经历了 this tut
我来找你是为了解决一个涉及多个不同文件的问题。我不确定为什么会收到标题中指定的错误。让我把文件放在下面,然后从那里开始。 虚拟客户端.cpp #include "Gameboard.h"
当我尝试编译我的 publishJoints 代码时,我不断收到错误消息,提示超出范围。 这里是 publishJoints.cpp 代码 #include #include #include
我有一个脚本正在复制一个包含几个子文件夹的文件夹。它从中复制的原始文件是 SVN 文件夹的一部分,因此它也在复制那些“.svn”文件夹。 我想从新目的地中删除那些,我最好的猜测是: rm -Rf di
我已经浏览了很多关于这个主题的其他问题/答案,但无济于事。 我使用 pip 下载了 numpy 和 nltk,根据消息我知道安装位置是: 要求已经满足(使用 --upgrade 升级):/usr/lo
我已经研究过了。 Stackoverflow 上已经有几篇关于此的帖子,但似乎都没有给我答案。 与此处的其他帖子一样,它在 Chrome 或 Firefox 中运行良好。但是在 IE 9、8、7 和
在我的单页应用程序中,特别是在 javascript 文件中,我收到一个错误,指出 reroll 函数的未捕获引用。我不明白是什么导致了这个问题。我的js文件设置有误吗?具体报错是,Reference
我想展现一个特殊的性格。 我找到了这个 link which displays everything . 让我们以这个字符为例: 2 个问题) 如何将 ↓ , ↓ 转换为 \u____unicode
我有一个 shiny看起来像这样的应用程序 ui.R shinyUI(fluidPage( titlePanel("Test Application"),
我认为这是一个非常愚蠢的问题,但我只是让自己感到困惑 我定义了几个 has_many 。我可以在实例方法中通过说 self 来引用它们。-------- 如果我尝试通过 @-------- 进行引用,
我收到以下编译错误:request for member ‘threeds’ in something not a structure or union 这是我的结构: struct pthread_
我正在使用我自己的 JAR 文件,它使用 Java 库 (JHDF5),后者又通过 JNI 使用 dll。当我在 MATLAB 中使用我自己的 JAR 文件,然后在调试时必须重建它时,在调用 clea
我是一名优秀的程序员,十分优秀!