### 重载=运算符实现 CStudent 类对象的赋值操作

答案：

#define MAX_LEN 128 //宏定义

class CStudent //定义 CStudent 类

{

public:

char m_szName[MAX_LEN];

int m_nAge;

void operator = (CStudent & std); //运算符重载

};

void CStudent::operator = (CStudent & std)

{

strcpy(m_szName, std.m_szName); //进行成员赋值

m_nAge = std.m_nAge;

}

int main(int argc, char* argv[])

{

CStudent std1, std2;

strcpy(std1.m_szName, "sk");

std1.m_nAge = 25;

std2 = std1;

cout << std2.m_szName << endl;

return 0;

}