title: When do I use '#include <string>' at the start of a C++ program?
body: <p>I am confused about the use of <code>#include &lt;string&gt;</code> at the start of a program. For example, in the code below, I don't use <code>#include &lt;string&gt;</code> but the function will still print out the string "Johnny's favorite number is" when it is run.</p>
  
  <pre><code>#include &lt;iostream&gt;
  using namespace std;
  
  void printVariable(int number){
      cout &lt;&lt; "Johnny's favorite number is" &lt;&lt; number &lt;&lt; endl
  }
  </code></pre>
  
  <p>However, in this code below, it does contain <code>#include &lt;string&gt;</code>.</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  class Var{
      public:
          void setName(string x){
              name = x;
          }
  
          string getName(){
             return name;
          }
     private:
         string name;
  };
  
  int main(){
      Var Classy;
      Classy.setName("Johnny Bravo");
      cout &lt;&lt; Classy.getName() &lt;&lt; endl;
      return 0;
  }
  </code></pre>
  
  <p>Do I only use <code>#include &lt;string&gt;</code> if a variable represents a string?</p>