title: How to use a vector of pointers to a structure in c++?
body: <p>I have an assignment that is due about a week from now. It is about making a letter counter (cases don't matter) of text file in the directory the source file is. Then the output of the letters should be, first, according to the letter with highest number of occurrences of it, and, second, if there are letters with the same number of occurrences, then sorting will be according to the alphabetical order. The assignment page is here: <a href="http://www.cs.sfu.ca/CourseCentral/135/tjd/a1.html" rel="nofollow">http://www.cs.sfu.ca/CourseCentral/135/tjd/a1.html</a>. I already did a program that has the same output (here it is: <a href="https://drive.google.com/file/d/0BxuBN4fpoq5LNHIwR2U2elVkdVE/view?usp=sharing" rel="nofollow">https://drive.google.com/file/d/0BxuBN4fpoq5LNHIwR2U2elVkdVE/view?usp=sharing</a>). The thing is, as what you can see from the assignment page, is that my proffisor is insisting that we use a vector, Freq_table, that has pointers to a structure, char_count. I tried to do simple code to add elements to the vector, like this:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;fstream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;math.h&gt;
  #include &lt;time.h&gt;
  #include &lt;vector&gt;
  
  using namespace std;
  
  struct char_count {
      char c;
      int count;
  };
  
  typedef vector&lt;char_count*&gt; Freq_table;
  
  int main () {
      char_count A_count = {'A', 0};
      Freq_table.push_back (A_count);
  }
  </code></pre>
  
  <p>But the compiler always gives this message:</p>
  
  <pre><code>error: expected unqualified-id before '.' token                                      
   Freq_table.push_back (A_count);
  </code></pre>
  
  <p>I can't seem to solve this error. All I need for now is to know what is the syntax of adding elements to a vector that has pointers to a structure.</p>
  
  <p>Regards.</p>