以下是Code :: Blocks
给出的EXACT错误D:\ cpp \ AdventureTimeTest \ main.cpp | 12 |错误:'class adventure'没有 名为'drawMap'的成员
这是我的代码: -
在main.cpp
中#include <iostream>
#include "adventure.h"
using namespace std;
int main()
{
adventure a;
a.setMapSize(10);
a.drawMap();
return 0;
}
在adventure.h中
class adventure
{
public:
adventure();
virtual ~adventure();
int mapSize;
void setMapSize(int mapSize);
int getMapSize();
void drawMap();
protected:
private:
};
最后,在adventure.cpp中
#include <iostream>
#include "adventure.h"
using namespace std;
adventure::adventure()
{
}
adventure::~adventure()
{
}
void adventure::setMapSize(int par1)
{
mapSize = par1;
}
int adventure::getMapSize()
{
return mapSize;
}
void adventure::drawMap()
{
for(int x = 0; x <= mapSize; x++)
{
for(int y = 0; y <= mapSize; y++)
{
cout << ". ";
}
cout << endl;
}
}
谢谢,希望我能很快解决这个问题。