In currently programming a simulation of algorithms to allocate memory. And it's giving me an anoing error with the class' definition. I can't tell why.![]()
I feel extremly noobed!!!![]()
Isn't Region suposed to inherit Block? The errors are in the constructors.Code://memory.h struct Block{ ADRESS adress; SIZE_T size; }; #define DEFAULT_REGION_SIZE ((SIZE_T)1024) #define BASE_REGION_ADRESS ((ADRESS)1024) const int MINBLOCKSIZE = 4; enum AllocEnum{ALLOC_FIRST_FIT,ALLOC_BEST_FIT,ALLOC_WORST_FIT}; class Region: private Block{ friend Block alloc_first_fit(Region& region, SIZE_T _size); friend Block alloc_best_fit (Region& region, SIZE_T _size); friend Block alloc_worst_fit(Region& region, SIZE_T _size); friend bool free(Region& region,DWORD adress); Block (*falloc)(Region& region, SIZE_T _size); public: Region( ADRESS base = BASE_REGION_ADRESS, SIZE_T _size = DEFAULT_REGION_SIZE, AllocEnum allocator = ALLOC_FIRST_FIT); Region(const Region&); inline ADRESS getBaseAdr() const; inline SIZE_T getSize() const; ADRESS alloc(SIZE_T _size); bool free(ADRESS adr); }; //memory.cpp Region::Region(ADRESS base,SIZE_T _size,AllocEnum allocator) : adress(base), size(_size),//error were falloc(allocator==ALLOC_FIRST_FIT?alloc_first_fit: (allocator==ALLOC_BEST_FIT?alloc_best_fit:alloc_worst_fit)){ } Region::Region(const Region& rg) : adress(rg.adress), size(rg.size), falloc(rg.falloc){//error here } //errors error C2614: 'Region' : illegal member initialization: 'size' is not a base or member error C2614: 'Region' : illegal member initialization: 'adress' is not a base or member error C2614: 'Region' : illegal member initialization: 'size' is not a base or member error C2614: 'Region' : illegal member initialization: 'adress' is not a base or member
NOTE: I don't want to skip the problem declaring the vars elsewhere. Thank you for your attention



LinkBack URL
About LinkBacks




I just noticed you were using private inhertance on Block. Instead use composition ie: