11
我實際上是試圖在我的內存管理器中實現Paging的模擬,我嘗試創建一個靜態頁表,但它給我參考錯誤,當我嘗試打印它。未定義的引用靜態成員函數裏面的靜態類成員變量
#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
充分利用了很久很久這個錯誤,請幫助
明白了:) 問題解決 –