Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ Programming: From Problem Analysis to Program Design (4th) step-by-step solu

ID: 3621029 • Letter: C

Question

C++ Programming: From Problem Analysis to Program Design (4th) step-by-step solutions: Chapter 15
Programming Exercise 16 is not posted. Having a bad time with this one. Please post the solution.

Explanation / Answer

Dear, a) StockType.h, StockType.cpp uses MyString class MyString #include #include #include #include using namespace std; class newString { //overload the stream insertion and extraction operators friend ostream& operator> (istream&, newString&); public: const newString& operator=(const newString& rightStr); //overload the assignment operator newString(const char *); //constructor; conversion from the char string newString(); //default constructor to initialize the string to null newString(const newString& rightStr); //copy constructor ~newString(); //destructor char &operator[] (int); const char &operator[](int) const; //overload the relational operators bool operator==(const newString& rightStr) const; bool operator!=(const newString& rightStr) const; bool operator(const newString& rightStr) const; private: char *strPtr; //pointer to the char array //that holds the string int strLength; //data member to store the length //of the string }; //overload the assignment operator const newString& newString::operator=(const newString &rightStr) { if(this != &rightStr) //avoid self-copy { delete [] strPtr; strLength = rightStr.strLength; strPtr = new char[strLength + 1]; assert(strPtr != NULL); strcpy(strPtr, rightStr.strPtr); } return *this; } //constructor; conversion from the char string newString::newString(const char *str) { strLength = strlen(str); strPtr = new char[strLength + 1]; //allocate memory to store char string assert(strPtr != NULL); strcpy(strPtr, str); //copy string into strPtr } //default constructor to initialize the string to null newString::newString() { strLength = 0; strPtr = new char[1]; assert(strPtr != NULL); strcpy(strPtr, ""); } //copy constructor newString::newString(const newString& rightStr) { strLength = rightStr.strLength; strPtr = new char[strLength + 1]; assert(strPtr != NULL); strcpy(strPtr, rightStr.strPtr); } //destructor newString::~newString() { delete [] strPtr; } char& newString::operator[] (int index) { assert(0 temp; rightStr = temp; return in; } StockType classes #ifndef H_stockType #define H_stockType #include #include #include "myString.h" using namespace std; class stockType { friend ostream& operator> (ifstream&, stockType&); public: void setStockInfo(newString symbol, double openPrice, double closeProce, double high, double Low, double prevClose, int shares); newString getSymbol(); double getPercentChange(); double getOpenPrice(); double getClosePrice(); double getHighPrice(); double getLowPrice(); double getPrevPrice(); int getNoOfShares(); stockType(); stockType(newString symbol, double openPrice, double closeProce, double high, double Low, double prevClose, int shares); int operator ==(stockType &other); int operator !=(stockType &other); int operator =(stockType &other); int operator >(stockType &other); int operator
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote