qfedu-cpp-level/day2/homework/h4.cpp

21 lines
378 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 1. 2. 创建一个名为 Circle 的类,具有成员变量 radius 和 pi圆周率以及成员函数 double calculateArea() ,用于计算圆的面积。
#include <iostream>
using namespace std;
class Circle
{
public:
double radius, pi = 3.1415926;
double calculateArea()
{
return pi * radius * radius;
}
};
int main()
{
return 0;
}