CPlusPlusThings/basic_content/static/static_variable.cpp

22 lines
229 B
C++

// variables inside a class
#include <iostream>
using namespace std;
class GfG {
public:
static int i;
GfG(){
// Do nothing
};
};
int GfG::i = 1;
int main() {
GfG obj;
// prints value of i
cout << obj.i;
}