Class Notes (806,741)
Canada (492,424)
CS 138 (14)
Lecture 3

Data Lecture 3.docx

4 Pages
Unlock Document

University of Waterloo
Computer Science
CS 138
Michael Godfrey

Data Lecture 3 January 15, 2012 C++ References  Thinking in C++ by Bruce Eckel o  Professional programmer help forum o  C++ Standard Library API reference o Advice  Always use curly brackets for if/switch/for/while  Use ++/-- operators as standalone stmt  Prefer for over while loops, if a for makes sense  struct vs. class o If you’re going to program in procedural style and not define methods per entity kind, then use STRUCTS o If you’re going to program in OO style and define methods per entity kind, use CLASSES to organize data and operations on them o Don’t mix struct and class Boolean type  Two special values: o True o False bool done=false; while (!done) { //do stuff if (…) {done=true;} }  C and C++ let you treat numbers as Boolean values o 0=false o 1=true if (n) (n==0) (p=NULL) (NULL == p) C++ strings  Much nicer, more convenient, and safer than char*  Only use char* when dealing with legacy C compatibility o Eg: argv[]  Need to say “#include #include … int main (…) { string fruit = “apple”; string tree=”pine”; cout << tree+fruit << endl; string f=tree+fruit; if (“pineapple”==f) { cout <
More Less

Related notes for CS 138

Log In


Don't have an account?

Join OneClass

Access over 10 million pages of study
documents for 1.3 million courses.

Sign up

Join to view


By registering, I agree to the Terms and Privacy Policies
Already have an account?
Just a few more details

So we can recommend you notes for your school.

Reset Password

Please enter below the email address you registered with and we will send you a link to reset your password.

Add your courses

Get notes from the top students in your class.