title: What are the differences between "typedef", "using", "namespace" and "using namespace" in C++?
body: <p>I find it difficult to get the exact meaning of these terms in C++. It seems like there is a lot of overlap between one another (at least typedef and namespace). Can you please enlighten me why were these concepts invented in C++; and in what scenarios should we use each one of these ?</p>
  
  <p>Also <a href="https://stackoverflow.com/questions/10747810/what-is-the-difference-between-typedef-and-using-in-c11">this</a> discussion is particularly confusing. It says 'typedef' and 'using' are the same. It makes me wonder, why do we have two different terms if they are almost the same ?</p>
  
  <p>Due to poor understanding of these terms I coded the following and got the error shown below:</p>
  
  <p><strong>Files.hpp</strong></p>
  
  <pre><code>#include &lt;boost/filesystem.hpp&gt;
  #include &lt;boost/filesystem/path.hpp&gt;
  #include &lt;boost/filesystem/operations.hpp&gt;
  #include &lt;iostream&gt;
  #include &lt;vector&gt;
  #include &lt;string&gt;
  #include &lt;utility&gt;
  #include &lt;algorithm&gt;
  #include &lt;fstream&gt;
  #include &lt;ostream&gt;
  #include &lt;iomanip&gt;
  #include &lt;cmath&gt;
  
  class Files {
  
  public:
  
  //@Brief: We create some short forms for long type names
  typedef boost::filesystem FS; //! Short form for boost filesystem
  // Short form for file name pairs (for example, &lt;200.jpg, 200&gt;)
  typedef std::pair&lt;FS::path, int&gt; file_entry;
  // Short form for vector of tuples
  typedef std::vector&lt;file_entry&gt; vec;
  // Short form for iterator of type, boost::filesystem::directory_iterator
  typedef FS::directory_iterator dirIter;
  };
  </code></pre>
  
  <p>The following is the <em>make</em> error that I receive:</p>
  
  <pre><code>...../include/Files.hpp:10:20: error: ‘filesystem’ in namespace ‘boost’ does not name a type
   typedef boost::filesystem FS; //! Short form for boost filesystem
  </code></pre>