How to use a method on a class object if method not defined in class c++
<p>I have class <code>Pstring</code> </p>

<pre><code>class Pstring
{
private:
   string palindrome;



public:
   Pstring() { palindrome = ""; }
   Pstring(string pal) { setString(pal); }
   void setString(string pal) { palindrome = pal; }
   string getPal() const { return palindrome; }


};
</code></pre>

<p>an object in my main method <code>Pstring palindrome(palin)</code> defined by</p>

<pre><code>   string palin = "";

   cout &lt;&lt; "Enter a palindrome:\n";
   getline(cin, palin);

   Pstring palindrome(palin);
</code></pre>

<p>and a current test method <code>bool isPalindrome(string pal)</code>defined as </p>

<pre><code>bool isPalindrome(string pal)
{
   bool flag; 

   cout &lt;&lt; "Do I have access to this?";
   cout &lt;&lt; pal; 

   //code goes here to check for palindrome, return bool

}
</code></pre>

<p>I want to have my Pstring class object palindrome use the method isPalindrome in main, but when I try and invoke the method by using <code>palindrome.isPalinedrome(palin);</code> it doesn't seem to have access to the method. </p>

<p>What can I do to allow a method outside the class to be used by a class object in main? </p>