I have defined a class like this:
class CircularBuffer {
private:
struct entry {
uint64_t key;
int nextPtr;
int prevPtr;
int delta;
};
int head, tail, limit, degree;
entry *en;
public:
CircularBuffer(int a, int b)
{
limit = a;
head = 0;
tail = limit -1;
degree = b;
en = new entry[ limit ];
for (int i=0; i<limit; i++) {
en[i].key = 0;
en[i].delta = 0;
en[i].nextPtr = 0;
en[i].prevPtr = 0;
}
};
~CircularBuffer() { delete [] en; }
};
And in another file I have included this class (the header file)
#include "circular.h"
class foo {
CircularBuffer cb;
foo() {} //ERROR LINE
void initialize() {
cb = new CircularBuffer(10, 2);
}
};
However this has error which says:
error: no matching function for call to ‘CircularBuffer::CircularBuffer()’
note: candidates are: CircularBuffer::CircularBuffer(int, int)
note: CircularBuffer::CircularBuffer(const CircularBuffer&)
and it forces me to do like this:
#include "circular.h"
class foo {
CircularBuffer cb;
foo()
: cb( CircularBuffer(10, 2) )
{}
void initialize() {}
};
However I don't want the second implementation. I want the first one. How can I fix that?