在C++的类的成员函数中,允许直接访问该类的成员对象的私有成员变量
// SmartPointerStu.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
//#include "SmartPointer.h"
//#include <iostream>
//using namespace std;
class CPointEx_
{
public:
//CPointEx_(int _x = 0, int _y = -1) : x(_x), y(_y) {}
void SetValue(int x, int y) { this->x = x, this->y = y; }
void CallPrivateMem(const CPointEx_& AObj)
{
x = AObj.x;
y = AObj.y;
}
private:
int x;
int y;
};
int _tmain(int argc, _TCHAR* argv[])
{
CPointEx_ theObj, theObj2;
theObj.SetValue(10, 20);
theObj2.SetValue(30, 40);
theObj2.CallPrivateMem(theObj);
system("pause");
return 0;
}