ifndef H_listType #define H_listType #include #include #include using namespace
ID: 3659738 • Letter: I
Question
ifndef H_listType #define H_listType #include #include #include using namespace std; template class listType { //class template to create an array and perform various functions public: bool isEmpty() const; bool isFull() const; int getLength() const; int getMaxSize() const; void sort(); void print() const; void insertAt(const elemType& item, int position); listType(int listSize = 50); ~listType(); protected: int maxSize; int length; elemType *list; }; template bool listType::isEmpty() const { //function to check if array is empty return (length == 0); } template bool listType::isFull() const { //function to check if array is full return (length == maxSize); } template int listType::getLength() const { //function to get length return length; } template int listType::getMaxSize() const { //function to get maxSize return maxSize; } template listType::listType(int listSize) { //default constructor maxSize = listSize; length = 0; list = new elemType[maxSize]; } template listType::~listType() { //destructor delete [] list; } template void listType::sort() { //sort function int i, j; int min; elemType temp; for(i = 0; i < length; i++) { min = i; for(j = i; j < length; ++j) if (list[j] < list[min]) min = j; temp = list[i]; list[i] = list[min]; list[min] = temp; } } template void listType::print() const { //print function int i; for(i = 0; i < length; ++i) cout << list[i] << " "; cout << endl; } template void listType::insertAt(const elemType& item, int position) { //insert function assert(position >= 0 && position < maxSize); list[position] = item; length++; } #endif #include #include #include "listType.h" using namespace std; class stockType { public: string stockSymbol; double open; double close; double high; double low; double previousClose; double percentGain; double volume; }; class stockListType: public listType { public: void arrayInput (int); void sortTndices(); void printIndices (int); private: int counter; int myArray[7]; int mystock; }; void arrayInput (int myArray) { int counter = 0; int arrayOfStruct = [myArray] for(counter = 0; counter < 50; counter++;) { infile >> arrayOfStruct[counter].stockSymbol; infile >> arrayOfStruct[counter].open; infile >> arrayOfStruct[counter].close; infile >> arrayOfStruct[counter].high; infile >> arrayOfStruct[counter].low; infile >> arrayOfStruct[counter].previousClose; infile >> arrayOfStruct[counter].percentGain; infile >> arrayOfStruct[counter].volume; } } void sortTndices () { int i = 0; for (i = 0; i < 50; i++); if (myArray[i] < myArray[i++]); } void printIndices () { int i = 0; for(i = 0; i < 50; i++) cout << stockType.stocksymbol << stockType.open; cout << stockType.close << stockType.high; cout << stockType.low << stockType.previousClose; cout << stockType.percentGain << stockType.volume << endl; }; #include #include #include "stockType.h" using namespace std; int main () { //need a test program here system ("pause"); return 0; }Explanation / Answer
the data is not clear. Please repost the question so that i can provide u the best possible answer....
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.