reviewing for final exam, need help with this question
Final exams are a couple of weeks away and I'm studying early because I need to past my c++ final with an 85 or higher. We recently had a test and the following question is one that I got most of it wrong. Can someone help me with it? There may be somthing like this on the final.
26) Consider the following header file (cross-section only -- more functions functions are possible):
Code:
//Filename: list.h -- Declaration of the class List
class List
{
public:
List(int x); // Initializes member data to represent empty list and
//dynamically allocates array to starting size x
int SumOdd();//returns the sum of all the odd numbers in the list
int Greater(int val); //returns the number of the values in the list
//that are greater than val
void PrintSquares(); //Prints the squares ofthe data elements in
// the list, separated by commas. Ex. if the
//list stores (3, 5, -2), prints 9, 25,4
private:
int * data;// pointer to a dymanic array of integer value
int current;//number of values currently stored in the list
int max; //the allocated size of the array
};
Write the 4 member functons declared here, exactly as they would appear in the implementation file "list.cpp".