// CSE 303, Spring 2009, Marty Stepp // This is our first example C++ program. // It is mostly just a syntax example and not a very useful program. // To compile it, use g++ -g -Wall -o hello hello.cpp #include using namespace std; void foo() { cout << "this is foo" << endl; } namespace marty { int main2(void) { return 0; } } // An example of references. // Like pointers, but more constrained and with simpler syntax. void swap(int& a, int& b) { int temp = a; a = b; b = temp; } int min(int a, int b) { int m; if (a < b) { m = a; } else { m = b; } return m; } int main(void) { cout << "Hello, world!" << endl; int age; cout << "How old are you Marty? "; cin >> age; int iq; cout << "What is your IQ Marty? "; cin >> iq; swap(age, iq); cout << "I am " << age << " years old and have IQ " << iq << endl; foo(); marty::main2(); return 0; }