//Box.h
#ifndef BOX_H
#define BOX_H
class Box
{
public:
Box(double aLength=1.0, double aWidth=1.0, double aHeight=1.0);
double volume() const;
double getLength() const;
double getWidth() const;
double getHeight() const;
bool operator<(const Box& aBox) const;
bool operator<(const double aValue) const;
// bool operator <(const double aValue, const Box& aBox) const;
private:
double length;
double width;
double height;
};
inline bool Box::operator <(const Box& aBox) const
{
return volume()<aBox.volume();
}
inline bool Box::operator<(const double aValue) const
{
return volume()<aValue;
}
inline bool operator <(const double aValue, const Box& aBox) const
{
return aValue<aBox.volume();
}
#endif
请帮我看下这个头文件的问题,我想语法上没有什么问题,可是就是VC6编译不过,说不是成员函数。
就是最后一个内联函数error C2270: '<' : modifiers not allowed on nonmember functions,我的邮箱seny@live.com,谢谢
#ifndef BOX_H
#define BOX_H
class Box
{
public:
Box(double aLength=1.0, double aWidth=1.0, double aHeight=1.0);
double volume() const;
double getLength() const;
double getWidth() const;
double getHeight() const;
bool operator<(const Box& aBox) const;
bool operator<(const double aValue) const;
// bool operator <(const double aValue, const Box& aBox) const;
private:
double length;
double width;
double height;
};
inline bool Box::operator <(const Box& aBox) const
{
return volume()<aBox.volume();
}
inline bool Box::operator<(const double aValue) const
{
return volume()<aValue;
}
inline bool operator <(const double aValue, const Box& aBox) const
{
return aValue<aBox.volume();
}
#endif
请帮我看下这个头文件的问题,我想语法上没有什么问题,可是就是VC6编译不过,说不是成员函数。
就是最后一个内联函数error C2270: '<' : modifiers not allowed on nonmember functions,我的邮箱seny@live.com,谢谢