编译错误.
Main.cpp: In constructor 'Triangle::Triangle(float, float, float)':
Main.cpp:17:1: error: expected '{' before 'float'
float area() override { // 实现面积计算
^
Main.cpp: In constructor 'Circle::Circle(float)':
Main.cpp:27:1: error: expected '{' before 'float'
float area() override { // 实现面积计算
^
Main.cpp: In function 'int main()':
Main.cpp:35:10: error: cannot declare variable 'tri' to be of abstract type 'Triangle'
Triangle tri(a, b, c); // 创建三角形对象
^
Main.cpp:13:7: note: because the following virtual functions are pure within 'Triangle':
class Triangle : public Shape {
^
Main.cpp:10:15: note:     virtual float Shape::area()
virtual float area() = 0; // 纯虚函数，由派生类实现具体算法
^
Main.cpp:36:8: error: no matching function for call to 'Circle::Circle()'
Circle cir; // 创建圆对象
^
Main.cpp:36:8: note: candidates are:
Main.cpp:26:1: note: Circle::Circle(float)
Circle(float r) : r {}
^
Main.cpp:26:1: note: candidate expects 1 argument, 0 provided
Main.cpp:23:7: note: constexpr Circle::Circle(const Circle&)
class Circle : public Shape {
^
Main.cpp:23:7: note: candidate expects 1 argument, 0 provided
Main.cpp:23:7: note: constexpr Circle::Circle(Circle&&)
Main.cpp:23:7: note: candidate expects 1 argument, 0 provided
Main.cpp:36:8: error: cannot declare variable 'cir' to be of abstract type 'Circle'
Circle cir; // 创建圆对象
^
Main.cpp:23:7: note: because the following virtual functions are pure within 'Circle':
class Circle : public Shape {
^
Main.cpp:10:15: note:     virtual float Shape::area()
virtual float area() = 0; // 纯虚函数，由派生类实现具体算法
^