I have an abstract class AbstractBufferQueue and BufferQueueAverage is the class which is being used in the code always.
class AbstractBufferQueue
{
virtual void addSample(int s) = 0;
virtual void removeSample(int s) = 0;
void enqueue(int val)
{
...
addSample(val);
}
}
class BufferQueueAverage : public AbstractBufferQueue
{
int n;
double mean;
void addSample(int s) { ++n; mean += (s - mean) / n; }
void removeSample(int s) { ... }
double getAverage() const { return mean; }
}
This question is from the compilers optimizations perspective.I want to know if we can make the virtual functions of the class AbstractBufferQueueAverage as inline.