"Oh, you are right, access to Class control should also be the same for Object control, but C selects Class. In this case," CMYSTRING A_COTHER variable m_pcdata is clearly private " It is not right, it should be understood as m_pcdata to non-CMYSTRING (inherited here first, not talking), but cannot understand that m_pcdata is private, "Zhou Xingxing (http: // blog). vckbase.com/bruceteen has made such a solution in the previous question.
According to what he meant, it should be the different objects Obja and Objb of the same class, and they should be private variables that can access each other. I did this attempt. New Class CTEST {public: void setValue; int getValue (); void setValue (ctest a_ctest); ctest (int a_ivalue = 0); Virtual ~ ctest ();
PRIVATE: INT M_ITEST;
The implementation of each function is as follows: CTEST :: Ctest (int a_ivalue) {m_itest = a_ivalue;}
CTEST :: ~ ctest () {}
Void ctest :: setValue (ctest & a_ctest) {m_itest = a_ctest.m_itest; A_CTEST.M_ITEST = -1;}
INT ctest :: getValue () {return m_itest;}
Void ctest :: setValue (int a_ivalue) {m_itest = a_ivalue;}
If he speaks is right, then the following program INT ITMP = 1; CTest CLSTEST1 (ITMP); CTest CLSTest2; CLSTest2.SetValue (clstest1); not only can be run, and the last result should be clstest1.m_itest == -1; CLSTEST2.M_ITEST == 2;
Exceive results in operation results.
Word Xingxing (http://blog.vckbase.com/bruceteen) is pair: Access rights should control the Class control or the object of Object is controlled in each language, but C selects CLASS. It seems that I still don't understand a lot, huh, huh, long way, I will ask for it.