08 lecture (midterm 2 review)

08 lecture (midterm 2 review) - 2) write the complete...

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

View Full Document Right Arrow Icon
5/16/08 Midterm 2 Chapter 5: -be able to write or analyze/find errors in functions -know the difference between value parameters and reference parameters (***look up passing reference parameters) - return valves/return types -function calls Chapter 6: -Be able to write or analyze/find errors in class code (or code that uses functionality of a class) -constructors/member functions/ dot-notation -data field access -implicit parameters vs. explicit parameters Chapter 7: - understand for and do and while loops - understand loops within loops (nested combinations) -section 7.8 on processing input -section 7.9 on simulation Chapter 9: -understand vectors and how to use them in functions and class codes -know how to write and analyze/find errors in code involving vectors -push_back, pop_back, and size practice quiz: 1)write the output of the code below: { c = 2; return c; } int func1 (int b) { func2 (b); return b; }
Background image of page 1

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

View Full DocumentRight Arrow Icon
int main() { int a = 1; int b = func1 (a); cout<< a << " " << b << "\n"; return 0; } //this code would output "1 2"
Background image of page 2
Background image of page 3
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 2) write the complete student class ( 2 fields, one int and one string). include defalt and regular constructor. include and accessor in each field. Class Student { public: Student ( ); Student (int a, string b); string get_name () const; int get_score () const; private: int score; string name; }; Student:: Student () { name = &quot; &quot;; score = 0; } Student:: Student( int a, string b) { score = a; name = b; } 3) write the output int main() { vector &lt;int&gt; z(6); z[0] = 23; z[1] = 77; z[2] = 41; z[3] = 98; z[4] = 46 ; z[5] = 62; for (int i = 5; i&gt;0; i-2) { z.pushback (z [ i ] ); } z.pop_back( z [ i ] ); cout &lt;&lt; z[ z.size( )-1 ] &lt;&lt; &quot;\n&quot;; return 0; } this code outputs 98. first it adds 77, then gets rid of it and then outputs the last number of the set. 4) write dow every combination of the statements that can execute int main() { if (condition 1) statement 1 if (condition 2) statement 2 else statement 3 return 0; } //the possible combinations would be:-1 and 2-1 and 3-2-3...
View Full Document

Page1 / 3

08 lecture (midterm 2 review) - 2) write the complete...

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

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