0

I have to create a program that uses a class Pstring derived from the STL class. The only error I am getting says that I have one unresolved external. How do I fix this? Here is my code:

#include <string>

class Pstring : public std::string
{
public:
    Pstring(const std::string &text)
        : std::string(text) { }

    bool isPalindrome()
    {
        std::string::size_type len = length();
        std::string::size_type half = len / 2;
        for (std::string::size_type idx = 0; idx < half; ++idx)
        {
            if ((*this)[idx] != (*this)[len-idx-1])
                return false;
        }
        return true;
    }
};

Edited by pritaeas: Moved to C++

3
Contributors
2
Replies
27
Views
3 Years
Discussion Span
Last Post by iamthwee
0

Odd that your prof is asking you to derive from a base STL class.

All the literature on the net suggests it's a no no. I'm sure there are better learning merits from deriving your OWN class as the syntax looks a little tricky as well.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.