{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

COS110 Tutorial 4-8August2011-MEMO

COS110 Tutorial 4-8August2011-MEMO - COS110 Tutorial 4 Date...

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

View Full Document Right Arrow Icon
1 COS110 Tutorial 4 MEMO-MEMO-MEMO Date: 10 August 2011 Time: 50 minutes Marks: 40 Student Surname and Initials:__________________________________________________ Student number:_______________________ Employee number:_____________________ Question 1 (string list ADT) [20 marks] Study the class specification given below and answer the questions that follow: class StringList { public: StringList(int size); ~StringList(void); void addString(const string &line, int position); string getString(int position); int getSize(void); int find(const string &line); private: string *list; int listSize; bool isValid(int position); void growList(int newSize); }; Write code for the following member functions: a. the constructor (1 marks) Solution: StringList::StringList(int size) { list = new string[size]; listSize = size; }
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