hello, ive got my code but ive split it up. however i keep getting the following errors:
--------------------Configuration: main - Win32 Debug--------------------
Compiling...
main.cpp
interpreter.cpp
D:\language systems ica\interpreter.cpp(16) : error C2065: 'Code_table' : undeclared identifier
D:\language systems ica\interpreter.cpp(16) : error C2109: subscript requires array or pointer type
D:\language systems ica\interpreter.cpp(16) : error C2228: left of '.instruction' must have class/struct/union type
parser.cpp
tables.cpp
Error executing cl.exe.main.exe - 3 error(s), 0 warning(s)
The H file that i want to access:
#ifndef TABLES_H
#define TABLES_H
#include <string>
using std::string;
typedef struct Sym_Table
{
string Name;
string type;
int address;
} Sym_Table;
typedef struct Code_Table
{
int oper_and;
int instruction_number;
string instruction;
} Code_Table;
static int stc = 1;
void add_symbol(string sym, string op_code);
void add_codeTable(string sym , int op_code);
void print_symbol_Table();
void build_code_table(string sym);
void print_code_Table();
int position(string &sym);
#endif
And im trying to access the structure in the following file and the following way:
#include <iostream>
#include <string>
#include "tables.h"
#include "interpreter.h"
using namespace std;
int tos = 1;
int pc =1 ;
int codearray;
int op;
void interpreter (void)
{
cout << Code_table[pc].instruction;
}
can anyone help? I've heard of extern but im not sure how to use it on structures.
Thanks
John