代码链接:https://github.com/laixiaolian/object-oriented
yuan.h
#define pi 3.14//全局变量
double circle(double r);//函数申明
yuan.cpp
#include"yuan.h"
double circle(double r)//函数定义
{
double area;
area = pi*r*r;
return area;
}
circle.cpp
#include"yuan.h"
#include<iostream>
using namespace std;
int main()
{
double area, r;
cin >> r;
area = circle(r);//调用函数
cout<< area << endl;
return 0;
}