1.函数重载回顾
- 函数重载的本质为相互独立的不同函数
- C++中通过函数名和函数参数确定函数调用
- 无法直接通过函数名得到重载函数的入口地址
- 函数重载必然发生在同—个作用域中
2.类中的重载
- 类中的成员函数可以进行重载
- 构造函数的重载
- 普通成员函数的重载
- 静态成员函数的重载
- 问题: 全局函数,普通成员函数以及静态成员函数之间是否可以构成重载?
3.万变不离其宗
- 1. 重载函数的本质为多个不同的函数
- 2. 函数名和参数列表是唯—的标识
- 3. 函数重载必须发生在同一个作用域中
#include<stdio.h>
class Test
{
int i;
public:
Test()
{
printf("Test::Test()\n");
this->i = 0;
}
Test(int i)
{
printf("Test::Test(int i)\n");
this->i = i;
}
Test(const Test &obj)
{
printf("Test(const Test &obj)\n");
this->i = obj.i;
}
static void func()
{
printf("void Test::func()\n");
}
void func