/* stuff in C++ */ using namespace std; #include #include void f(int& x, int& y) { int t = x; x = y; y = t; } void g(int x) { cout << "G\n"; } int h() { cout << "H\n"; return 2; } void e(bool z, int x, int y) { if (z) cout << x; else cout << y; cout << endl; } int x = 1; int s(int y) { return x+y; } class A { public: int x; int y; A(int x0, int y0) { x=x0; y = y0; } virtual int sum() { return x +y; } void print() { cout << x << " " << y << endl; } }; class B : public A { public: int z; B(int x0, int y0, int z0) : A(x0,y0) { z = z0; } int sum() { return A::sum() + z; } }; int main(int argc, char** argv) { int x = 2, y = 3; f(x,y); cout << x << " and " << y << endl; g(h()); // does it have to be this way? ORDER OF EVAL x = 2; // cout << 1/(x-2) << endl; //e(1>2, 1/(x-2), 3); { int x = 4; cout << x << endl; } cout << x << endl; x = 2; cout << s(4) << endl; // 5 or 6? A m = B(1,2,3); A *n = new B(1,2,3); cout << m.sum() << endl; cout << n->sum() << endl; // (*n).sum() return 0; }//main