先看书上的做法
class noCC
{
int i;
noCC(const noCC&); //声明一个私有的构造函数,而且没有定义(无所谓)
public:
noCC(int I=0):i(I){};
};
void g(const noCC n){};
main() 这么写
noCC n;
g(n); //erro
noCC n1=n; //erro
noCC n2(N); //erro
都是 cannot access private member declared in class 'noCC'
其实 还有方法就是指声明构造函数,不实现 也没能实现这个目的。
把noCC(const noCC&); 放到public 里去
error LNK2001: 无法解析的外部符号 "public: __thiscall noCC::noCC(class noCC const &)" (??0noCC@@QAE@ABV0@@Z)
不是也行吗