I'm working on creating a simulator for RISC.
Below are a different part of codes relevant to my question.
main.cpp
memory* main_memory;
processor* cpu;
main_memory = new memory (verbose); //memory classs implemented correctly
cpu = new processor (main_memory, verbose);
interpret_commands(main_memory, cpu);// takes to commands class
In processor.cpp, I have to access a function of memory class that is public.
memory.cpp:
uint32_t memory::read_word (uint32_t address) {
// some calculation and returns a hex word at address
}
processor.cpp:
#include "memory.h"
void processor::execute(unsigned int num, bool breakpoint_check){
if(some condition){
//call read_word at address
}
}
I do have a parameterized constructor in processor.cpp that has memory class pointer:
processor::processor(memory* main_memory, bool verbose){
}
The question is, how can I call read_word function(of class memory) from the execute function (of class processor)?
Any help would be highly appreciated :)