文章目录
一、概述

二、内容
6.1、函数基础

#include "LocalMath.h"
#include <iostream>
using std::cout; using std::endl;
int main()
{
// pass a literal to fact
int f = fact(5); // f equals 120, i.e., the result of fact(5)
cout << "5! is " << f << endl;
// call fact on i and print the result
int i = 5;
int j = fact(i);
cout << i << "! is " << j << endl;
// call fact on a const int
const int ci = 3;
int k = fact(ci);
cout << ci << "! is " << k << endl;
return 0;
}










6.2、参数传递









这个难理解








6.3、返回值类型和Return语句










6.4、函数的重载











6.5、特殊用途语言特性







constexpr



调试





6.6函数匹配








6.7、函数指针





函数指针形参



6.8、小结

6.9、术语表


本文深入探讨了C++中的函数基础,包括如何传递参数、函数的重载以及特殊语言特性如`constexpr`。通过实例展示了函数在不同情况下的应用,如对常量和变量调用函数,以及函数指针的使用。同时,文章还涵盖了函数匹配和调试技巧,是学习C++函数知识的重要参考资料。
33万+

被折叠的 条评论
为什么被折叠?



