midterm_review - CSE 332 Midterm Review Goals for today's...

Info iconThis preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE 332: C++ program structure and development environment CSE 332 Midterm Review Goals for today’s review Review and summary of material in course so far A chance to clarify and review key concepts/examples Discuss details about the midterm exam In class during the next class period (80 minutes) One 8.5”x11” face of notes + pencils/pens allowed All electronics must be off, including cell phones, etc. Recommendations for exam preparation Catch up on any studio exercises you’ve not done Write up your notes page as you study Ask questions here and on the message board
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 332: C++ program structure and development environment Writing a C++ Program C++ source files (ASCII text) .cpp Programmer (you) emacs editor C++ header files (ASCII text) .h 1 source file = 1 compilation unit Makefile (ASCII text) Also: .C .cxx .cc Also: .H .hxx .hpp readme (ASCII text) Eclipse Visual Studio
Background image of page 2
CSE 332: C++ program structure and development environment Lifecycle of a C++ Program C++ source code Makefile Programmer (you) object code (binary, one per compilation unit) .o make “make” utility xterm console/terminal/window Runtime/utility libraries (binary) .lib .a .dll .so gcc, etc. compiler link linker E-mail executable program Eclipse debugger precompiler compiler link turnin/checkin An “IDE” WebCAT Visual Studio window compile
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CSE 332: C++ program structure and development environment What Goes Into a C++ Program? Declarations: data types, function signatures, classes Allows the compiler to check for type safety, correct syntax Usually kept in “header” (.h) files Included as needed by other files (to keep compiler happy) class Simple { public: typedef unsigned int UINT32; Simple (int i); void print_i (); void usage (); private: int i_; }; Definitions: static variable initialization, function implementation The part that turns into an executable program Usually kept in “source” (.cc) files void Simple::print_i () { cout << “i_ is ” << i_ << endl; } Directives: tell compiler (or precompiler) to do something #include <vector> using namespace std;
Background image of page 4
CSE 332: C++ program structure and development environment Using C++ vs. C-style Strings #include <string> #include <iostream> using namespace std; int main (int, char*[]) { char * w = “world”; string sw = “world”; char * h = “hello, ”; string sh = “hello, ”; cout << (h < w) << endl; // 0: why? cout << (sh < sw) << endl; // 1:why? h += w; // illegal: why? sh += sw; cout << h << endl; cout << sh << endl; return 0; } C-style strings are contiguous arrays of char Often accessed through pointers to char ( char * ) C++ string class (template) provides a rich set of overloaded operators Often C++ strings do “what you would expect” as a programmer Often C-style strings do “what you would expect” as a machine designer Suggestion: use C++ style strings any time you need to change, concatenate, etc.
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/19/2011 for the course CSE 332S taught by Professor Smart during the Spring '08 term at Washington University in St. Louis.

Page1 / 46

midterm_review - CSE 332 Midterm Review Goals for today's...

This preview shows document pages 1 - 6. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online