title: C++ Get Total File Line Number
body: <p>Is there a function I can use to get total file line number in <code>C++</code>, or does it have to be manually done by <code>for</code> loop?</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;ifstream&gt;
  
  ifstream aFile ("text.txt");
  if (aFile.good()) {
  //how do i get total file line number?
  
  }
  </code></pre>
  
  <p><em>text.txt</em></p>
  
  <pre><code>line1
  line2
  line3
  </code></pre>