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