类的实现,高手快进!!!!!!!!!! 自己写一个类,类名自己定义,主要实现 拷贝构造 函数的功能,但是类成员变量里面一定要有指针,CString,CWindThread等类型的变量,我查了好多资料都没有明白是怎么回事,也不知道怎么写出来! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 但是类成员变量里面一定要有指针,CString,CWindThread-----------------看《深入浅出MFC》 也许会有收获~ class MyClass{public: int nLen; char * pData;public: MyClass(){nLen=0; pData=NULL;}; ~MyClass() {nLen = 0; delete pData; }; MyClass(const MyClass& temp) {nLen=temp.nLen; pData=new char[nLen];memcpy(pData, temp.pData, nLen);}; MyClass& operator = (const MyClass& temp) { if ( pData != temp.pData ) { // 这里特殊,防治 a = a;这种赋值发生 delete pData; nLen = temp.nLen; pData = new char[nLen]; memcpy(pData, temp.pData, nLen); // 这里不能够简单的用 pData = temp.pData;替换,否则会出问题的。 } return * this; }; Copy(const MyClass& temp) { *this = temp; };}; 数据库关闭问题 ATL中使用QueryControl 就会有问题!请帮忙! 无模式属性页Create不出现窗口 sql server?????? 请问怎样把一个listbox分成多列使用 关于编译原理 通过blur方法让IHTMLElement2失去焦点失败? VS解决方案资源管理器里文件前面红点是啥意思? nodetype *p=new nodetype(3); 那delete p后p是否一定是NULL(0)呢? 打开IE? 新手上路: 如何判断鼠标的形状发生变化?在线等 如何判断BSTR类型变量是否为空?
-----------------
看《深入浅出MFC》 也许会有收获~
{
public:
int nLen;
char * pData;
public:
MyClass(){nLen=0; pData=NULL;};
~MyClass() {nLen = 0; delete pData; };
MyClass(const MyClass& temp) {nLen=temp.nLen; pData=new char[nLen];memcpy(pData, temp.pData, nLen);};
MyClass& operator = (const MyClass& temp) {
if ( pData != temp.pData ) { // 这里特殊,防治 a = a;这种赋值发生
delete pData;
nLen = temp.nLen;
pData = new char[nLen];
memcpy(pData, temp.pData, nLen);
// 这里不能够简单的用 pData = temp.pData;替换,否则会出问题的。
}
return * this;
};
Copy(const MyClass& temp) { *this = temp; };
};