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
    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;

Recommended Answers

All 2 Replies

I don't get any errors with that code using VC++ 2012. The error is probably somewhere else.

Member Avatar

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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.