title: Friend function in class defined in namespace
body: <p>I'm trying to make a function in <code>DataBase</code> namespace declared in <code>DataBase.h</code> file with implementation in <code>DataBase.cpp</code> that needs an access to a protected member of <code>Collection</code> class.</p>
  
  <p>Here is what i currently have</p>
  
  <p><code>Collection.h</code>:</p>
  
  <pre><code>class Collection
  {
     ...
  protected:
     string name;
     friend Collection&amp; DataBase::getCollection(string name);
  };
  </code></pre>
  
  <p><code>DataBase.h</code>:</p>
  
  <pre><code>namespace DataBase {
      ...
      Collection&amp; getCollection(std::string collectionName);
  }
  </code></pre>
  
  <p><code>DataBase.cpp</code>:</p>
  
  <pre><code>namespace DataBase {
      ...
      Collection&amp; getCollection(std::string collectionName)
      {
          for (auto&amp; collection : _collections)
              if(collection.name == collectionName)
              {
                 ...
              }
      }
  
  }
  </code></pre>
  
  <p>The problem is I can't access name property.</p>