I am working on a homework assignment, and I have almost everything done except for this obnoxious static value that our professor wishes us to use: value
The header file contains:
private:
static int value;
And we have to have a function calculate the value, like so:
static void calculate()
{
long a = 1L;
int count = 0;
while( a != 0 )
{
a = a << 1;
count++;
}
value = count;
}
This is essentially calculating the number of bits in a long, using bit shifting.
However, I am getting the error " undefined reference to `Class1::value'
I've spent the last hour and a half figuring this out, and it's killing me. Any help would be great, all searches have come up dead.
Thanks!
Update:
I included
int Class1::value = 0;
However, now I am getting an error saying "error: int Class1::value is private
See Question&Answers more detail:os