mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-03 18:43:52 +08:00
english
This commit is contained in:
24
english/basic_content/static/static_variable.cpp
Normal file
24
english/basic_content/static/static_variable.cpp
Normal file
@@ -0,0 +1,24 @@
|
||||
// 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;
|
||||
}
|
||||
Reference in New Issue
Block a user