Pointer to a object class throwing "does not name a type"
I have开发者_StackOverflow中文版 a hardware class having a pointer to a TLB class object, and initialising that in the constructor. However, Codeblocks (GNU GCC) is giving me the error "proj3_hardware.h|15|error: 'TLB' does not name a type" "proj3_hardware.h|15|error: expected ';' before '*' token"
I just cannot see where is the error in the code. Thank you.
proj3_hardware.h
#include <iostream>
#include "proj3_globals.h"
#include "proj3_pagetable.h"
#include "proj3_tlb.h"
class Hardware{
public:
// Defines the hardware parts
int global_simulation_time;
TLB* tlb;
PageManagement* pagemm;
// Hardware constructor and methods
Hardware(int pageTableType, int replacementAlgo);
void execute();
void diskaccess();
};
proj3_tlb.h
#include <iostream>
#include "proj3_globals.h"
// Assumes that the TLB is using LRU
class TLBEntry{
public:
char validEntry;
int VirtualAddress;
int PhysicalAddress;
long LastUsed;
};
class TLB{
private:
TLBEntry entries[HARDWARE_TLBSIZE];
int* simulation_time;
public:
TLB(int* simulation_time);
void tlb_add(int virtualaddress, int physicaladdress);
int tlb_lookup(int virtualaddress);
void tlb_flush();
};
Compiles for me.
The error must be in other code; Check your other header files for:
- any suspicious
#define
s - missing semicolons?
- wrong include guards (this one is my best guess)
精彩评论