1_26_07_DiscussionNotes

1_26_07_DiscussionNotes - UCLA CS32 Discussion Notes 1/26/07

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

View Full Document Right Arrow Icon
Topics on 1/26/07: I. Doubly-linked list. II. Copy construction. III. Assignment operator. IV. Stack V. Debugging. I. Doubly-linked list: Write a function called insert that accepts three NODE pointers as arguments: nodea nodeb newnode When your function is called, nodea is directly linked to nodeb. Your function should insert newnode between nodea and nodeb as we saw in the last example. struct NODE { int val; NODE *next, *prev; }; void insert(Node *nodea, Node *nodeb, Node *newnode) { newnode->next = nodea -> next; newnode->prev = nodeb -> prev; nodea->next = newnode; nodeb->prev = newnode; } ______________ II. Copy Construction: CS32 section1(30, "Kevin"); CS32 section2(section1); // CS32 section2 = section1; 1. There is a time when you need to declare your copy constructor. Syntax: class CS32 { public: CS32(int c, char *s) { m_count = c; m_TAname = new char[strlen(s)]; // check strlen construction strcpy(m_TAname, s); } m_count = oldvar.m_count; m_TAname = new char[m_count];
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 12/06/2009 for the course CS cs32 taught by Professor John during the Winter '09 term at UCLA.

Page1 / 2

1_26_07_DiscussionNotes - UCLA CS32 Discussion Notes 1/26/07

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

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