day2: const 和#define 的区别, 引用(reference) 【重要】, 内联函数, 函数的默认值参数, 函数的占位参数, 函数重载和extern c, 类与对象的概念, 面向对象程序设计案例

This commit is contained in:
2023-07-25 20:05:25 +08:00
parent fd11f165fb
commit 220ea31d68
21 changed files with 702 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
#include "area.h"
double S(double r)
{
return r * r * 3.1415926;
}
+15
View File
@@ -0,0 +1,15 @@
#ifndef __AREA_H__
#define __AREA_H__
// 条件编译
#if __cplusplus
extern "C"
{
#endif
double S(double r);
#if __cplusplus
}
#endif
#endif
+12
View File
@@ -0,0 +1,12 @@
#include <iostream>
#include "area.h"
using namespace std;
int main()
{
double r = 2.5;
double s = S(r);
cout << "S(2.5) = " << s << endl;
return 0;
}