求助解决bug C++

#include <iostream>
using namespace std;

/*
 练习案例1:设计立方体类 Cube
     1.求出立方体的面积和体积
    2.分别用全局函数和成员函数判断两个立方体是否相等 
*/

class Cube{
    private:
        int mlength;
        int mwidth;
        int mheight;
        
    public:
        int getLength(int length){
            mlength = length;
        }
        int setLength(){
            return mlength;
        }
        
        int getWidth(int width){
            mwidth = width;
        }
        int setWidth(){
            return mwidth;
        }
        
        int getHeight(int height){
            mheight = height;
        }
        int setHeight(){
            return mheight;
        }
        
        int setVolume(){
            return mlength*mwidth*mheight;
        }
        
        //利用成员函数判断(类里面是成员函数,类外面是全局函数)
        bool isSameByClass(Cube c){
            if(mheight == c.getHeight() && mwidth==c.getWidth() && mlength==c.getLength()){
                return true;
            }else{
                return false;
            }
        } 
};


int main(){
    Cube c1;
    c1.getLength(12);
    c1.getWidth(2);
    c1.getHeight(23);
    cout<<c1.setVolume()<<endl;
    
    Cube c2;
    c2.getLength(12);
    c2.getWidth(2);
    c2.getHeight(23);
    
    bool ret = c1.isSameByClass(c2);
    cout<<ret<<endl;
}

 

运行一直显示error: no matching function for call to Cube::getHeight()

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值