对不完全类型“class Point *”的非法使用

在实现检查点是否在圆上的C++项目中,遇到'对不完全类型“class Point *”的非法使用'错误。问题源于Point类的声明顺序。正确做法是确保在使用Point指针之前已经完整声明了Point类。修复此问题后,程序正常运行。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

今天我在写一个比较点是否在圆上的一个小项目的时候,遇到了这个错误:
在这里插入图片描述
源代码是这样的

#include <iostream>
#include <cmath>
using namespace std;



class Circle
{
private:
    //圆半径
    double r;
    //圆心坐标
    double x0;
    double y0;
public:
    Circle()
    {
        cout<<"please input the circle's radius : ";
        cin>>r;
        cout<<"please input the circle's coordinate  "<<endl;
        cout<<"x : ";
        cin >> x0;
        cout<<"y : ";
        cin >> y0;
    }
    void compare(class Point &p)
    {
        double x1,y1;
        double d2;//距离之平方
        x1 = p.getX1();
        y1 = p.getY1();
        d2 = pow((x0-x1),2)+pow((y0-y1),2);//(x0-x1)^2+(y0-y1)^2 即不含根号的距离公式
        if(d2==pow(r,2))
            cout<<"the point is on the circle"<<endl;
        else if(d2 > pow(r,2))
            cout<<"the po
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值