I have 2 classes: Database and DatabaseMgr. The functions in DatabaseMgr need to access the variables in Database. To my understanding, I can declare DatabaseMgr a friend class to Database or inherit DatabaseMgr from Database.
Code:
class Database
{
friend class DatabaseMgr;
public:
/*constructors/destructors*/
protected:
/*member variables*/
};
....or
Code:
class DatabaseMgr:public Database
{
public:
/*functions that access the member variables of Database
};
So my question is, whats the difference? Do both methods give me the same outcome?