R
Rahul
Hi Everyone,
I have the following code,
class Sample
{
public: static int i;
void f()
{
Sample::i = 5;
}
};
int main()
{
Sample obj;
obj.f(); // Causes linker error saying unresolved
external symbol Sample::i...
}
It works fine, if the following statement is added before main and
after the class declaration,
int Sample::i;
Does the above statement take care of memory allocation for the
static member variable?
I have the following code,
class Sample
{
public: static int i;
void f()
{
Sample::i = 5;
}
};
int main()
{
Sample obj;
obj.f(); // Causes linker error saying unresolved
external symbol Sample::i...
}
It works fine, if the following statement is added before main and
after the class declaration,
int Sample::i;
Does the above statement take care of memory allocation for the
static member variable?