为什么说未定义标识符

出现这种情况怎么办!!

img

#include 
#include 
//using namespace Cube;
//#include 
using namespace std;

class Cube {
public:
    void setlong(int l)
    {
        m_l = l;
    }

    int getlong()
    {
        return m_l;
    }

    void setweight(int w)
    {
        m_w = w;
    }

    int getweight()
    {
        return m_w;
    }

    void setheight(int h)
    {
        m_h = h;
    }

    int getheight()
    {
        return m_h;
    }

    int getS()
    {
        return 2 * m_l + 2 * m_h + 2 * m_w;
    }

    int getV()
    {
        return m_l * m_h * m_w;
    }

    //利用成员函数判断
    bool isSamebyclass(Cube &c)
    {
        if (m_l == c.getlong() && m_h == c.getheight() && m_w == c.getweight())
        {
            return true;
        }

        return false;
    }
private:
    int m_l, m_h, m_w;

    //利用全局函数判断两个立方体是否相等
    bool issame(Cube &c1, Cube &c2)
    {
        if (c1.getheight() == c2.getheight() && c1.getlong() == c2.getlong() && c1.getweight() == c2.getweight())
        {
            return true;
        }

        return false;
    }

};

int main()
{
    Cube c1;

    c1.setlong(10);
    c1.setweight(10);
    c1.setheight(10);

    cout << "面积:" << c1.getS() << endl;
    cout << "体积:" << c1.getV() << endl;

    Cube c2;
    c2.setlong(10);
    c2.setweight(10);
    c2.setheight(10);

    bool ret=issame(c1, c2);

    //全局函数判断
    if (ret)
    {
        cout << "c1与c2相等" << endl;
    }
    else
    {
        cout << "c1与c2不相等" << endl;
    }

    //成员函数判断
    bool ret2 = c1.isSamebyclass(c2);
    if (ret2)
    {
        cout << "成员函数:c1与c2相等" << endl;
    }
    else
    {
        cout << "成员函数:c1与c2不相等" << endl;
    }
    system("pause");

    return 0;
}

issame是类的私有成员函数,在main里直接写issame肯定不认识啊
一来你需要将issame改成公有函数,main里才能调用,二来建议将issame改成只有一个参数,让参数中的变量与当前类的成员变量比较。调用时改为bool ret = c1.issame(c2);或者将issame改成静态函数,调用时写成 bool ret = Cube::issame(c1,c2);

issame函数是类中私有方法函数,不是全局函数