Course_review - CSE 332 Semester Review Goals for todays review Review and summary of the material this semester A chance to clarify and review key

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

View Full Document Right Arrow Icon
CSE 332 Semester Review CSE 332 Semester Review Goals for today’s review Review and summary of the material this semester A chance to clarify and review key concepts/examples Discuss details about the final exam 6-8pm (2 hours) this Friday (Dec 11) in Cupples II 217 Two 8.5”x11” faces 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 pages 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 Semester Review 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 2
CSE 332 Semester Review C Strings, C++ Strings, and Streams #include <iostream> #include <fstream> #include <sstream> using namespace std; int main (int, char*[]) { ifstream ifs (“in.txt”); if (ifs.is_open ()) { string line_1, word_1; getline (ifs, line_1); istringstream iss (line_1); iss >> word_1; cout << word_1 << endl; } return 0; } <sstream> header file Use istringstream for input Use ostringstream for output Useful for scanning input Get a line from file into string Wrap string in a stream Pull words off the stream Useful for formatting output Use string as format buffer Wrap string in a stream Push formatted values into stream Output formatted string to file
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 Semester Review Untangling Operator Syntax Symbol Used in a declaration Used in a definition unary & (ampersand) reference, e.g., int i; int &r = i; address-of, e.g., p = & i; unary * (star) pointer, e.g., int * p; dereference, e.g., * p = 7; -> (arrow) member access via pointer, e.g., C c; C * cp=&c; cp->add(3); . (dot) member access via reference or object, e.g. , C c; c.add(3); C & cr = c; cr.add(3);
Background image of page 4
CSE 332 Semester Review Review: What’s a Pointer? A variable holding an address Of what it “points to” in memory Can be untyped E.g., void * v; // points to anything However, usually they’re typed Checked by compiler Can only be assigned addresses of variables of type to which it can point E.g., int * p; // only points to int Can point to nothing E.g., p = 0; // points to nothing Can change where it points As long as pointer itself isn’t const E.g., p = &i; // now points to i 0x7fffdad0 7 int i int *p
Background image of page 5

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

View Full DocumentRight Arrow Icon
CSE 332 Semester Review Review: What’s a Reference? Also a variable holding an address Of what it “refers to” in memory But with a nicer interface A more direct alias for the object Hides indirection from programmers Must be typed Checked by compiler Again can only refer to the type with which it was declared E.g. , int & r =i; // refers to int i Always refers to (same) something Must initialize to refer to a variable Can’t change what it aliases 0x7fffdad0 7 int i int & r
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 03/03/2010 for the course CSE 241 taught by Professor Cse241 during the Spring '08 term at Washington University in St. Louis.

Page1 / 58

Course_review - CSE 332 Semester Review Goals for todays review Review and summary of the material this semester A chance to clarify and review key

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

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