C++ How do I start this? Using an appropriate definition of ListNode, design a s
ID: 3672450 • Letter: C
Question
C++
How do I start this?
Using an appropriate definition of ListNode, design a simple linked list class called StringList with the following member functions:
The add() function adds a new node containing the value of the parameter to the end of the list. The positionOf() function returns the (zero-based) position in the list for the first occurrence of the parameter in the list, or -1 if that value is not in the list. In the setNodeVal() function, the first parameter represents a (zero-based) position in the list. The setNodeVal() function sets the value of the node at that position to the value of the string parameter. If the position parameter is >= the number of nodes in the list, the operation cannot be carried out and setNodeVal() should return false, otherwise it should be successful and return true. The getAsVector() function returns a vector with the same size, values and order as the StringList. The default constructor should initialize a new empty StringList object. The copy constructor should create a completely separate duplicate of a StringList object (a deep copy). The destructor should delete any memory that was dynamically allocated by the StringList object.
Files must be called: StringList.hpp and StringList.cpp
Explanation / Answer
Canhelp you with this
#include <string_list.h>
class StringListConstIterator
{
public:
StringListConstIterator();
StringListConstIterator(const StringList *pMotherStringList);
StringListConstIterator(const StringListConstIterator& other);
~StringListConstIterator();
bool hasNext() const;
std::string next();
std::string previous();
std::string current();
};
class StringList
{
public:
StringList();
StringList(const StringList& other);
const StringList& operator=(const StringList& other);
~StringList();
StringListConstIterator const_iterator() const;
void addStringFront(const std::string& str);
void addStringBack(const std::string& str);
std::vector<std::string> getAsVector(void) const;
bool isEmpty(void) const;
};
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.