I'm getting the title error at runtime inside method SetNameandOp on the lines where I try to add something to the RealList struct. I think I am referencing RealList wrong, but I am not sure how to correct it. Anyone have any thoughts?
Here are the structs in the headerfile:
class Instructions
{
public:
//methods
struct myInstruction
{
string name;
string opcode; //opcode of add, addi etc.
string rs; //2nd paramter
string rt; //3rd
string rd; //1st
string shamt; //shift amount
string function;
myInstruction* next;
}InstructionList;
}
class greenCard
{
public:
//methods
struct
{
string name;
string opcode;
string function;
} Instructions[29];
}
methods:
Instructions::InputtedInstructions* Instructions::get_instruction(vector<string>& vec, int counter)
{
InputtedInstructions* InputList = new InputtedInstructions[counter];
myInstruction* RealList = new myInstruction[counter];
while (ListPosition != counter)
{
string text = vec.at(ListPosition);
istringstream iss(text);
string command, arg1, arg2, arg3;
int CommaAmount = count(text.begin(), text.end(), ',');
if (CommaAmount == 2)
{
while( iss >> command >> arg1 >> arg2 >> arg3)
{
setNameandOp(RealList, InputList[ListPosition].name, counter);
ListPosition++;
}
}
}
return InputList;
}
void Instructions::setNameandOp(myInstruction* RealList, string set, int counter)
{
greenCard NameSet;
int y = NameSet.instructionsearch(set);
if (y != -1)
{
RealList[counter].name = NameSet.Instructions[y].name;
RealList[counter].opcode = NameSet.Instructions[y].opcode;
RealList[counter].function = NameSet.Instructions[y].function;
}
}
int greenCard::instructionsearch(string realinstruction)
{
int i;
for (i=0; i < 29; i++)
{
if ( realinstruction.compare(Instructions[i].name) == 0)
return i;
}
return -1;
}
if anything is unclear let me know. Id be more than happy to explain deeper if need be. I just am not sure what else to put without questions.