Home cpp oop overload
Post
Cancel

cpp oop overload

Example

1
2
3
4
5
6
7
int sum(int v1, int v2) {
		return v1 + v2;
}

int sum(int v1, int v2, int v3) {
  	return v1 + v2 + v3;
}

Note

  • 函数名称+参数(个数及顺序)构成重载
  • C语言是不支持重载的

Name Mangling or Name Decoration

  • C++默认会对符号名(如函数名)进行改编、修饰
  • 重载的实现原理

References

https://ke.qq.com/webcourse/336509/100476446#taid=3185688912929405&vid=5285890793442483881

This post is licensed under CC BY 4.0 by the author.