title: C++ call class method from within class
body: <p>I have a class that implements a linked list. The class has a find() method which finds a value if it exists in the linked list. I have another method add() which adds a node, but ONLY if that value contained in that node does NOT already exist in the list. </p>
  
  <p>So what I want to do in my add() function is use my find method instead of testing for an existing value since that'd be like implementing it a second time. My question is, how can I call the find method from within another method in that class?</p>
  
  <p>I tried calling
      this.find(x)</p>
  
  <p>But that gave me errors.</p>
  
  <p>Here is what some of my code looks like:</p>
  
  <pre><code>// main function
    SLList&lt;int&gt;list;
    list.add(20);
    list.add(14);
  
  // SLList.h (interface and implementation)
  
  template&lt;typename T&gt;
  bool SLList&lt;T&gt;::find(const T&amp; val) const {
    // finds value
  }
  
  
  template&lt;typename T&gt;
  void SLList&lt;T&gt;::add(const T&amp; x) {
    bool found = this.find(x);
    if (found) return false;
  
    // goes on to add a node in the Singly Linked list (SLList)
  }
  </code></pre>
  
  <p>So Like I said, I want to be able to call the find method from within another method in that class, and I thought all I'd have to do for that is refer to the calling object, and then call it's find method, but as I said, this gives me a bunch of errors.</p>
  
  <p>Anyone help me out with how I can call this, thank you!</p>