title: C++ testing void methods using gtest
body: <p>I have just started to Unit Test in C++ using gtest, and I have a question regarding the testing of void methods.</p>
  
  <p>Say I have a method void printNames(), which prints the names of all the students in a class.</p>
  
  <ol>
  <li><p>Using testing, is there a way to check whether the method is printing the right names or not? </p></li>
  <li><p>Or, is it even needed to test for such a thing?</p></li>
  <li><p>I can make the method return string, and then test the returned string with a string that concatenates all the names of the students in the class. Would that be a "good" solution?</p></li>
  </ol>