zbMidterm 1 Review

zbMidterm 1 Review - Wednesday,February1st MidtermReview Be...

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

View Full Document Right Arrow Icon
Wednesday, February 1st Midterm Review 1. Classes, construction, destruction 2. Class composition, initializer lists 3. Pointers and references 4. Dynamic memory allocation (new/delete) 5. Linked lists (doubly linked too) 6. Copy constructors and assignment operators Be able to read and write code using: 1. Stacks and Queues Be able to read code using:
Background image of page 1

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

View Full Document Right Arrow Icon
Review Problem #1 struct NODE { int val; NODE *next; }; Write a function called  swapFirstTwo  which  swaps the first two items in a linked list (if there are at  least two items) class LinkedList  {  public:     …    void swapFirstTwo();    … private:     Node *m_head; };
Background image of page 2
Problem #2  class MagicPower { public:      MagicPower() { cout << “MP\n”; }     ~ MagicPower() { cout << “~MP\n”; } }; class Wand { public:     Wand() { cout << “Wand\n”; }     ~Wand() { cout << “~Wand\n”; }     private:     MagicPower myPower; }; class Wizard { public:      Wizard()  { cout << “Wizard\n”; }      ~Wizard()  { cout << “~Wizard\n”; } private:      Wand myWand;      Wand *secondWand; }; int main() {      Wizard *carey;      carey = new Wizard;     Wizard david[2]; } What does this program print?
Background image of page 3

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

View Full Document Right Arrow Icon
class Stomach { public:      Stomach(string items[], int n)       {             count = n;             if (n <= 3)  // if <= 3 items then use array             {               for (int i=0;i<n;i++)                     contents[i] = items[i];             }             else          // otherwise use new to alloc array
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 10

zbMidterm 1 Review - Wednesday,February1st MidtermReview Be...

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

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