2023-03-30 00:15:11 +08:00
|
|
|
// variables inside a class
|
2019-07-14 20:39:17 +08:00
|
|
|
|
2023-03-30 00:15:11 +08:00
|
|
|
#include <iostream>
|
|
|
|
|
using namespace std;
|
2019-07-14 20:39:17 +08:00
|
|
|
|
2023-03-30 00:15:11 +08:00
|
|
|
class GfG {
|
|
|
|
|
public:
|
|
|
|
|
static int i;
|
2019-07-14 20:39:17 +08:00
|
|
|
|
2023-03-30 00:15:11 +08:00
|
|
|
GfG(){
|
|
|
|
|
// Do nothing
|
|
|
|
|
};
|
|
|
|
|
};
|
2019-07-14 20:39:17 +08:00
|
|
|
|
2023-03-30 00:15:11 +08:00
|
|
|
int GfG::i = 1;
|
2019-07-14 20:39:17 +08:00
|
|
|
|
2023-03-30 00:15:11 +08:00
|
|
|
int main() {
|
|
|
|
|
GfG obj;
|
|
|
|
|
// prints value of i
|
|
|
|
|
cout << obj.i;
|
|
|
|
|
}
|