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

9th Nov 2016, 5:44 PM
Ù‡ÙˆÙ†Û•Ű± ŰčÙˆÙ…Û•Ű±
Ù‡ÙˆÙ†Û•Ű± ŰčÙˆÙ…Û•Ű± - avatar
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;};}
9th Nov 2016, 9:04 PM
Gunther Strauss
Gunther Strauss - avatar