我了解到,我永远不能访问私有变量,只能使用类中的 get 函数。但是为什么我可以在复制建构子里找到它?
例如:
Field::Field(const Field& f)
{
pFirst = new T[f.capacity()];
pLast = pFirst + (f.pLast - f.pFirst);
pEnd = pFirst + (f.pEnd - f.pFirst);
std::copy(f.pFirst, f.pLast, pFirst);
}
我的声明:
private:
T *pFirst,*pLast,*pEnd;