mirror of
https://github.com/Light-City/CPlusPlusThings.git
synced 2026-02-04 02:54:42 +08:00
update dir
This commit is contained in:
26
static/static_error_variable.cpp
Normal file
26
static/static_error_variable.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
// variables inside a class
|
||||
|
||||
#include<iostream>
|
||||
using namespace std;
|
||||
|
||||
class Apple
|
||||
{
|
||||
public:
|
||||
static int i;
|
||||
|
||||
Apple()
|
||||
{
|
||||
// Do nothing
|
||||
};
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
Apple obj1;
|
||||
Apple obj2;
|
||||
obj1.i =2;
|
||||
obj2.i = 3;
|
||||
|
||||
// prints value of i
|
||||
cout << obj1.i<<" "<<obj2.i;
|
||||
}
|
||||
Reference in New Issue
Block a user