using namespace std;
static int c; //declaring static c initialised to zero
//before first object created
c++; //increment static variable
static int d; //public static
int sample::c=0; //definition of c
int sample::d; //definition of d
1. Should static variable always be created outside the access specifier?
2. What will happen if i declare the variable inside public?
3. Where all do we have to use the static funtion?
4. Should it be only static variables for static funtions?
4. It's less "should" and more "must". If you try to access a non-static member from a static member the compiler will reject the program (unless you do it via an instance of the class). Non-static members can use static members, however.