The different functions of the derived class are put here:
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "digital_sim.h"
SignalChangedEvent::SignalChangedEvent(unsignedint t, Wire * vector, bool v)
{
time= t;
value = v;
outputWires[i]= value;
}
void SignalChangedEvent::processEvent (bool a)
{
value = a;
wire->set_value(value);
wire->process();
}
I get an error when running this part of the code:
1 2 3 4 5 6 7
void And2::process()
{
bool outputValue = inputBits[0] & inputBits[1];
for (unsignedint i = 0; i < outputWires.size(); i++)
theSimulation.scheduleEvent(new SignalChangedEvent(theSimulation.time + delay, outputWires[i], outputValue));
}
It says:
error: cannot allocate an object of abstract type 'SignalChangedEvent'
note: because the following virtual functions are pure within 'SignalChangedeEvent'
I have looked through the whole thing a couple of times, but I can't seem to find the problem in it.
Any help? :(
Your function signatures for processEvent are different between class Event and class SignalChangedEvent.
virtualvoid processEvent () = 0;
virtualvoid processEvent(bool);
The first takes no arguments, while the second is expecting a bool.
The compiler will see these as different functions and the second will not override the pure virtual.