我正在嘗試創建一個計算圓的面積的類Circle
。它使用的初始化2點,一個爲中心,一個爲上圓(又名半徑),這些都是我得到了錯誤的點爲基點類:使用C++中的Point類創建一個類來計算圓的面積
(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
也許我在,如果一直盯着太久長,但任何幫助,將不勝感激。
#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);
}