I have a static variable in the class. I initialize that on a global scale his work is beautiful.
But when I try to initialize in the main linker, an error occurs. Why is this so.
class Myclass{
static int iCount;
} ;
int main(){
int Myclass::iCount=1;
}
And In the global scope, I have to specify the type of the variable as
int Myclass::iCount=1;
As in my class, I define iCount as an integer type, why not.
Myclass::iCount =1 ; in
source
share