title: error: request for member ... which is of non-class type
body: <p>I realize the error is coming from using vectors in a custom class, but I have been struggling how to fix them. How do I call vector methods when its part of the class object?</p>
  
  <p>These are the errors I am getting:</p>
  
  <pre><code>Word.cpp: In member function ‘void Word::addPosition(int)’:
  Word.cpp:20: error: request for member ‘push_back’ in ‘((Word*)this)-&gt;Word::positions’, which is of non-class type ‘std::vector&lt;int, std::allocator&lt;int&gt; &gt;*’
  Word.cpp: In member function ‘int Word::getPosition(int)’:
  Word.cpp:26: error: request for member ‘size’ in ‘((Word*)this)-&gt;Word::positions’, which is of non-class type ‘std::vector&lt;int, std::allocator&lt;int&gt; &gt;*’
  Word.cpp:27: error: request for member ‘size’ in ‘((Word*)this)-&gt;Word::positions’, which is of non-class type ‘std::vector&lt;int, std::allocator&lt;int&gt; &gt;*’
  Word.cpp:29: error: cannot convert ‘std::vector&lt;int, std::allocator&lt;int&gt; &gt;’ to ‘int’ in return
  </code></pre>
  
  <p>Header</p>
  
  <pre><code>#pragma once
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  class Word {
    public:
      Word();
      ~Word();
      void setWord(std::string);
      void addPosition(int);
      std::string getWord();
      int getPosition(int);
    private:
      std::string word;
      std::vector&lt;int&gt; *positions;
  };
  </code></pre>
  
  <p>Implementation</p>
  
  <pre><code>#include "Word.h"
  #include &lt;string&gt;
  #include &lt;vector&gt;
  
  Word::Word() {
      this-&gt;word = "";
      this-&gt;positions = new std::vector&lt;int&gt;(5);
  }
  
  void Word::setWord(std::string s) {
      this-&gt;word = s;
  }
  
  void Word::addPosition(int i) {
      this-&gt;positions.push_back(i);
  }
  
  std::string Word::getWord() {
      return this-&gt;word;
  }
  
  int Word::getPosition(int i) {
      if (i &lt; this-&gt;positions.size() &amp;&amp; i &gt; 0) {
          for (int j = 0; j &lt; this-&gt;positions.size(); i++) {
              if (i == j) {
                  return positions[j];
              }
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>edit: Is this a better way to set up the class?
  header: </p>
  
  <pre><code>    #pragma once
      #include &lt;string&gt;
      #include &lt;vector&gt;
  
      class Word {
        public:
          Word();
          ~Word();
          void setWord(std::string);
          void addPosition(int);
          std::string getWord();
          int getPosition(int);
        private:
          std::string word;
          std::vector&lt;int&gt; positions;
      };
  </code></pre>
  
  <p>implementation: </p>
  
  <pre><code>Word::Word(){
      word = "";
  }
  
  void Word::setWord(std::string s){
      this -&gt; word = s;
  }
  void Word::addPosition(int i){
      this -&gt; positions.push_back(i);
  }
  std::string Word::getWord(){
      return this -&gt; word;
  }
  int Word::getPosition(int i){
      if (i &lt; this -&gt; positions.size() &amp;&amp; i &gt; 0) {
          for (int j = 0; j&lt;this -&gt; positions.size(); i++) {
              if (i == j) {
                  return (this-&gt;positions)[j];
              }
          }
      }
      return -1;
  }
  </code></pre>
  
  <p>but now I am getting this error:</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "_main", referenced from:
        start in crt1.10.6.o
  ld: symbol(s) not found for architecture x86_64
  collect2: ld returned 1 exit status
  </code></pre>