Z
zhangyefei.yefei
class String
{
public:
String & operate=(const String *other)
{
delete m_data;
m_data=new char[strlen(other.m_data)+1];
strcpy(m_data,other.m_data);
}
private:
char *m_data;
}
in the above calss, why memeber function can access the object other's
private m_data?
according to Principle of Encapsulation ,a boject can not access other
object's private memeber.
do anyone give me any explanation ?
thanks in advance
..
{
public:
String & operate=(const String *other)
{
delete m_data;
m_data=new char[strlen(other.m_data)+1];
strcpy(m_data,other.m_data);
}
private:
char *m_data;
}
in the above calss, why memeber function can access the object other's
private m_data?
according to Principle of Encapsulation ,a boject can not access other
object's private memeber.
do anyone give me any explanation ?
thanks in advance
..