0
What is and how to use static int in c++
i saw 'static int' somewhere but i dont know how and where to use it .. i dont fully understand it
1 Answer
0
you use static if you need this member variable or method working without creating an object of this class.
to create an object means something like this:
classname object;
object.methode();
class classname{
int method() {return 0;};
}
but maybe you want something like
classname.ObjectAlreadyExist();
here you may have an object but it is not necessary!
class classname {
static classname ObjectAlreadyExist() {return this;};}