Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Creating a program where I have to create my own c string class that will be used to read in data from files and then

Creating a program where I have to create my own c string class that will be used to read in data from files and then make use of a classifier. I am not sure where to start, and am just looking for some guidance on what steps I should take to start the creation of the class. Below is the template of the code given to me so far for the custom string class. I am not looking for any code, just trying to understand how to start and accomplish this part of the project.

#ifndef PA01_SENTIMENT_DSSTRING_H #define PA01_SENTIMENT_DSSTRING_H #include #include class DSString{ private: /** * You will need to add some private data members here. * This is up to your discretion. However, we **strongly** * encourage you to implement your string class as a wrapper * for typical null-terminated c-strings. In doing this, you * may use c-sting functions in the methods in this class such * as: * * strlen(...) * * strcpy(...) * * strcmp(...) * * strncpy(...) * * strcat(...) * * strncat(...) * * A quick google search will return plenty of references on * the c-string functions. **/ public: /** * Constructors and destructor * * Make sure you do proper memory management. **/ DSString(); DSString(const char*); DSString(const DSString&); ~DSString(); /** * Overloaded Assignment Operators */ DSString& operator= (const char*); DSString& operator= (const DSString&); /** * Overloaded non-modifying string concat * @return */ DSString operator+ (const DSString&); /** * Standard relational operators. Feel free to add additional. * * Note that for each operator, there are two overloaded versions: * one that takes a DSString object * one that takes a null-terminated c-string * **/ bool operator== (const char*); bool operator== (const DSString&); bool operator> (const DSString&); bool operator> (const char*); /** * Subscript operator to access a particular character of a DSString object * @return the character requested by reference */ char& operator[] (const int); /** * getLength() returns the number (count) of characters in the string. **/ int getLength(); /** * The substring method returns a string object that contains a * sequence of characters from this string object. * * param start - the index of where to start * param numChars - the number (count) of characters to copy into * the substring * @return a DSString object containing the requested substring **/ DSString substring(int start, int numChars); /** * the c_str function returns a null-terminated c-string holding the * contents of this object. **/ char* c_str(); /** * Overloaded stream insertion operator to print the contents of this * string to the output stream in the first argument. **/ friend std::ostream& operator<< (std::ostream&, const DSString&); //You are free to add more functionality to the class. For example, //you may want to add a find(...) function that will search for a //string within a string. (just an example) // //Further - you will be able to update and modify this class as the //semester progresses. }; #endif //PA01_SENTIMENT_DSSTRING_H

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

PC Magazine Guide To Client Server Databases

Authors: Joe Salemi

1st Edition

156276070X, 978-1562760700

More Books

Students also viewed these Databases questions

Question

What is your role in the investment process?

Answered: 1 week ago