I am actually trying to implement a simulation of Paging, in my memory manager, i tried create a static page table, but its giving reference error when i try to print it.
#ifndef MEMORYMANAGER_H
#define MEMORYMANAGER_H
#include "memory.h"
class MemoryManager
{
private:
PhysicalMemory RAM;
LogicalMemory VM;
int offsetValue;
static int ** pageTable;
public:
MemoryManager();
bool addProcess(TimeSliceRequest);
void printVirtualMemory();
/*
* Page Table Initialization
**/
static void initializePageTable(){
pageTable = new int * [pageSize];
for (int i=0; i<pageSize; i++) {
pageTable[i] = new int [2];
}
}
static int getPageTabe(int x, int y) {
return MemoryManager::pageTable[x][y]; // undefined reference to `MemoryManager::pageTable'
}
static void printPageTable(){
for(int i=0; i<pageSize; i++){
for(int j=0; j<2; j++) {
cout << getPageTabe(i,j);
}
cout << endl;
}
}
};
#endif // MEMORYMANAGER_H
Getting this Error from a long long time, please help
You only declare the pageTable
member variable, you have to define it as well. This is done by basically repeating the declaration in an implementation (source) file:
int ** MemoryManager::pageTable;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With