#include <iostream>
using namespace std;
class Obj {
private:
int c;
public:
Obj(int cc):c(cc) {
cout << "Obj::Obj()for" << c++ << endl;
}
~Obj() {
cout << "Obj::~Obj()for" << c++ << endl;
}
};
int c = 1;
int d = 5;
Obj a(c);
void f() {
static Obj b(d);
}
int main() {
cout << "inside main()" << endl;
f();
cout << "leaving main()" << endl;
printf("c = %d, d = %d\n", c, d);
return 0;
}
#include <iostream>
using namespace std;
int a = 10;
void f() { cout << --a; }
struct S {
int a;
void f();
};
void S::f() {
a = 20;
::f();
::a++;
a--;
cout << a;
}
int main()
{
S s;
s.f(); //f();
return 0;
}
#include <iostream>
using namespace std;
class Obj {
private:
int c;
public:
Obj(int cc):c(cc) {
cout << "Obj::Obj()for" << c++ << endl;
}
~Obj() {
cout << "Obj::~Obj()for" << c-- << endl;
}
};
int c = 0;
Obj a(++c);
void f() {
static Obj b(++c);
}
int main() {
cout << "inside main()" << endl;
f();
cout << "leaving main()" << endl;
printf("c = %d\n", c);
return 0;
}