S
Stefan Istrate
Hello,
I have the following code and I still don't know why it prints "10 10"
instead of "5 10".
#include <iostream>
using namespace std;
class A {
static int i;
public:
static int get_i() {
return i;
}
static int dbl() {
i = i * 2;
return i;
}
};
int A::i = 5;
int main() {
cout << A::get_i() << " " << A::dbl() << endl;
return 0;
}
Can anyone help me understand this?
Thank you,
Stefan Istrate
I have the following code and I still don't know why it prints "10 10"
instead of "5 10".
#include <iostream>
using namespace std;
class A {
static int i;
public:
static int get_i() {
return i;
}
static int dbl() {
i = i * 2;
return i;
}
};
int A::i = 5;
int main() {
cout << A::get_i() << " " << A::dbl() << endl;
return 0;
}
Can anyone help me understand this?
Thank you,
Stefan Istrate