I am not really good in c++ so I really need your help. I am using a method inside an object and I would like to access other object members. How can I do that in a better way and not violating OOP?
This is my .h
class XSection
{
private:
char *m_sname;
XSection *m_snext;
};
class XIniFile
{
private:
char *m_iname;
XSection *m_isections;
XSection *addSection(const char *);
}
and I have something like this in .cpp
XSection *XIniFile::addSection(const char *d)
{
XSection *sn = (XSection *) malloc (sizeof(XSection *));
sn->m_sname = strdup(d);
return sn;
}
I am having an error of char* XSection::m_sname is private char *m_name;
How could I use it?