字达云 2020-04-21 20:18 采纳率: 100%
浏览 246
已结题

【C++】不能将参数 1 从“Rect”转换为“int”(用的软件是VS2010)

图片说明

#include<iostream>
using namespace std;
class Point
{
    int x,y;
public:
    Point(int x=0,int y=0):x(x),y(y)
    {}
    int getX(){return x;};
    int getY(){return y;};
    void disp(){cout<<'('<<x<<','<<y<<')';}
};
class Rect
{
    Point ptLtTp,ptRtDn;
public:
    Rect(Point ptLT,Point ptRD):ptLtTp(ptLT),ptRtDn(ptRD)
    {}
    Rect(int x1=0,int y1=0,int x2=0,int y2=0):ptLtTp(x1,y1),ptRtDn(x2,y2)
    {}
    Rect(Rect &r):ptLtTp(r,ptLtTp),ptRtDn(r,ptRtDn)
    {}
    void disp()
    {
        ptLtTp.disp();
        ptRtDn.disp();
        cout<<endl;
    }
};
int main()
{
    Point p1(3,3),p2(5,5);
    Rect rect1,rect2;
    rect1=Rect(p1,p2);
    rect2=Rect(1,1,4,4);
    rect1.disp();
    rect2.disp();
    Rect rect3(rect2);
    rect3.disp();
    return 0;
}
  • 写回答

2条回答 默认 最新

  • Huoon 2020-04-21 22:01
    关注

    Rect(Rect &r):ptLtTp(r,ptLtTp),ptRtDn(r,ptRtDn)这一句写错了。

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 5月19日
  • 已采纳回答 12月16日

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料