UW CSE 303 - Study Notes (6 pages)

Previewing pages 1, 2 of 6 page document View the full content.
View Full Document

Study Notes



Previewing pages 1, 2 of actual document.

View the full content.
View Full Document
View Full Document

Study Notes

78 views


Pages:
6
School:
University of Washington
Course:
Cse 303 - Concepts and Tools for Software Development
Concepts and Tools for Software Development Documents

Unformatted text preview:

12 2 2009 The plan 11 30 C intro 12 2 C intro 12 4 12 7 12 9 12 11 Final prep evaluations 12 15 Final HW7 is out new PM due date Finish last lecture David Notkin Autumn 2009 CSE303 Lecture 25 CSE303 Au09 References References vs pointers type name variable reference A variable that is a direct alias for another variable any changes made to the reference will affect the original like pointers but more constrained and simpler syntax an effort to fix many problems with C s implementation of pointers Example int x 3 int r x r now use r just like any int r 4 x 4 value on right side of must be a variable not an expression cast Reference parameters returntype name type name client passes parameter using normal syntax if function changes parameter s value client variable will change you almost never want to return a reference except in certain cases in OOP 2 don t use and to reference dereference just at assignment cannot refer directly to a reference just refers to what it refers to a reference must be initialized at declaration int r error a reference cannot be reassigned to refer to something else int x 3 y 5 int r x r y sets x 5 r 5 a reference cannot be null and can only be invalid if it refers to an object memory that has gone out of scope or was freed const and references const Constant cannot be changed used much much more in C than in C can have many meanings const pointer to a const int void printSquare const int i i i i error cout i endl int main int i 5 printSquare i 1 12 2 2009 Strings String methods method include string append str C actually has a class for strings much like Java strings but mutable can be changed not the same as a literal or a char but can be implicitly converted string str1 Hello impl conv c str Concatenating and operators string str3 str1 str2 if str1 str2 compares characters if str1 str3 compares by ABC order char c str3 0 first character String concatenation description append another string to end of this one return a const char for a C



View Full Document

Access the best Study Guides, Lecture Notes and Practice Exams

Loading Unlocking...
Login

Join to view Study Notes and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Study Notes and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?