以其他对象作为参数创建对象时
# Student.h
Student(Student&);
# Student.cpp
// 复制构造函数
Student::Student(Student& student)
{
strcpy(m_name,student.m_name);
m_age=student.m_age;
strcpy(m_addr,student.m_addr);
}
# main.cpp
Student student;
Student stu(student);
类对象(传值)作为函数参数时
void func(Student stu)
{
cout<<stu.getAge();
}
// 执行了复制构造函数
func(student);