P
Philipp.Weissenbacher
Hi all!
I've got something of a design issue here:
class Bucket {
public:
// Initial capacity of a bucket (= # of items in a page)
static const unsigned int M = 10;
// Key store
Key keyStore[M];
// Count of items in the bucket
int count;
// Bucket's depth (number of significant bits)
int localDepth;
Bucket();
~Bucket();
};
Now, I use Bucket in a data structure like this:
#include "Bucket.h"
Foobar::Foobar() : a(0), b(0), c(0) {
}
void Foobar buzz() {
if(Bucket::M < 1)
...
}
Although this compiles just fine, if I want to use it e.g. write
something like
#include "Foobar.h"
int maint() {
Foobar* b = new Foobar();
}
I get a "undefined reference" from ld. Googling on this I found out
that I have one has to initialize a static variable in exactly one
compilation unit (see [10.10] Why can't I initialize my static member
data in my constructor's initialization list? by Marshall Cline).
But how do I fix this?
Thanks in advance,
Philipp
I've got something of a design issue here:
class Bucket {
public:
// Initial capacity of a bucket (= # of items in a page)
static const unsigned int M = 10;
// Key store
Key keyStore[M];
// Count of items in the bucket
int count;
// Bucket's depth (number of significant bits)
int localDepth;
Bucket();
~Bucket();
};
Now, I use Bucket in a data structure like this:
#include "Bucket.h"
Foobar::Foobar() : a(0), b(0), c(0) {
}
void Foobar buzz() {
if(Bucket::M < 1)
...
}
Although this compiles just fine, if I want to use it e.g. write
something like
#include "Foobar.h"
int maint() {
Foobar* b = new Foobar();
}
I get a "undefined reference" from ld. Googling on this I found out
that I have one has to initialize a static variable in exactly one
compilation unit (see [10.10] Why can't I initialize my static member
data in my constructor's initialization list? by Marshall Cline).
But how do I fix this?
Thanks in advance,
Philipp