Last Week Function Pointers Object Oriented C Overview Intro to C++ History Extensions of C class access methods Intro to C++ ============ History C with class invented by Bjarne Stroustup around 1981 ATT in order to build telephone switch simulations. Based the language on lessons learned from Simula '67 a language designed to write simulation programs. C with classes was little more than what we saw last week. i.e. struct with member functions. Extensions to C 1. Most C programs can be compiled with C++ (some type problems) 2. Classes ! 3. overloaded (what is that?) methods + functions void push(int); void push(float); 4. New input/output class Basic unit to declare an object class point { public: point (int x, int y); move (int dx, int dy); private: int x; int y; }; >> How is this different from Java? private and public sections No code in class (just declarations) >> You would probably put this in a header file point.h #ifndef POINT_H #define POINT_H class point {...} #endif >> What does the #ifndef do for you? >> In the .cc you put the method definitions :: point::point (int x1, int y1) { x = x1; y = y1; } >> What do x and y refer to? >> Write and compile a program hello.cc #include main () { cout << "hello world" << endl; } >> compiling $ g++ -o hello hello.cc Input-Output cout --stdout cin '' stdin cerr --stderr usage is different int x; float y; cout << "this is an int " << x << " and this is a float " << y <> x; cin >> y;