D:\CodeBlocks\TheRPG\Level.cpp|45|error: invalid types 'int[int]' for array subscript|
D:\CodeBlocks\TheRPG\Level.cpp|51|error: invalid types 'int[int]' for array subscript|
in Level.cpp
<pre>#include "Level.h"
#include <iostream>
#include "Enemy.h"
#include "Data.h"
#include <windows.h>
#include <fstream>
#include <string>
using namespace std;
void Level::getID()
{
fstream fluxi("ID.txt",ios::in);
for(int i=0; i<20; i++)
{
fluxi>>ID[i]>>IDP[i]>>IDN[i];
}
fluxi.close();
system("PAUSE");
}
Level::Level()
{
}
Level::Level(float g,int e,int l ,int s)
: gold(g),exp(e),lvl(e),stage(s)
{
}
void Level::showInventory()
{
fstream fluxo("INV.txt",ios::in);
k=0;
while(!fluxo.eof())
{
fluxo>>IDO[k]>>IDPO[k]>>IDNO[k];
k++;
}
for(int i=0; i<k; i++)
{
cout<<"Item LVL:"<<IDO[i]<<" ATK:"<<IDPO[i]<<" "<<IDNO[i]<<" Sword";
}
}
void Level::addInventory()
{
fstream fluxoa("inv.txt",ios::out | ios::app);
}
void Level::editInventory()
{
fstream fluxoa("inv.txt",ios::out | ios::app);
}
void Level::stage1()
{
getID();
while(gameOver==false)
{
system("CLS");
cout<<"\n\t\tLvl:"<<lvl<<" Exp:"<<exp<<" Gold:"<<gold<<" Stage:"<<stage<<endl;
system("PAUSE");
}
}
void Level::stage2()
{
}
void Level::stage3()
{
}
in Level.h
#ifndef LEVEL_H
#define LEVEL_H
#include "Data.h"
#include "Enemy.h"
class Level
{
public:
Level();
Level(float g,int e,int l ,int s);
void stage1();
void stage2();
void stage3();
private:
void getInventory();
void editInventory();
void showInventory();
void addInventory();
void getID();
float gold;
int lvl,stage,exp;
int ID[21];
int IDP[21];
int IDO[21];
int IDPO[21];
int k;
char IDN[21][10];
char IDNO[21][10];
bool gameOver;
};
#endif // LEVEL_H
What is wrong with the code?
What I have tried:
D:\CodeBlocks\TheRPG\Level.cpp|45|error: invalid types 'int[int]' for array subscript|
D:\CodeBlocks\TheRPG\Level.cpp|51|error: invalid types 'int[int]' for array subscript|