day2: const 和#define 的区别, 引用(reference) 【重要】, 内联函数, 函数的默认值参数, 函数的占位参数, 函数重载和extern c, 类与对象的概念, 面向对象程序设计案例
This commit is contained in:
@@ -0,0 +1,6 @@
|
||||
#include "area.h"
|
||||
|
||||
double S(double r)
|
||||
{
|
||||
return r * r * 3.1415926;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef __AREA_H__
|
||||
#define __AREA_H__
|
||||
|
||||
// 条件编译
|
||||
#if __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
double S(double r);
|
||||
|
||||
#if __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user