我正在尝试创建一个Circle
计算圆面积的类。它使用一个基本的 Point 类来初始化 2 个点,一个作为中心,一个作为圆上的一个点(又名半径)这些是我得到的错误:
(25) error C2533: 'Circle::{ctor}' : constructors not allowed a return type
(25) error C2511: 'Circle::Circle(Point &,Point &)' : overloaded member function not found in 'Circle'
(12) : see declaration of 'Circle'
(46): fatal error C1004: unexpected end-of-file found
也许我已经盯着 if 太久了,但任何帮助将不胜感激。
#include <iostream>
#include <cmath>
#include "Point.h"
class Circle
{
public:
Circle(const Point &, const Point &);
float getArea() const;
private:
Point pCenter;
Point p1;
float areaOfCircle;
}
Circle::Circle(Point &pointC, Point &point1)
: pCenter(pointC), p1(point1)
{
}
float Circle::getArea() const
{
areaOfCircle = 3.14159 * pow(pCenter.distanceTo(p1),2);
return areaOfCircle;
}
int main()
{
Point pointCenter
cout << "The center point is at: " //pointCenter.getX() << ","
<< pointCenter.getY() << endl;
cout << "A point on the circle is at: " //pointRadius.getX() << ","
<< pointRadius.getY() << endl;
cin.ignore(2);
}