11

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

1 Answer 1

22

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;
0

Not the answer you're looking for? Browse other questions tagged or ask your own question.