本文整理汇总了C++中Rectangle::Area方法的典型用法代码示例。如果您正苦于以下问题:C++ Rectangle::Area方法的具体用法?C++ Rectangle::Area怎么用?C++ Rectangle::Area使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Rectangle
的用法示例。
在下文中一共展示了Rectangle::Area方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrintObject
void PrintGeometricObject::PrintObject(Rectangle& r)
{
// Todo
cout << "Rectangle\n";
cout << " length: " << r.length_ << " " << r.measurementUnit_ << "\n";
cout << " height: " << r.height_ << " " << r.measurementUnit_ << "\n";
cout << " circumference: " << r.Circumference() << " " << r.measurementUnit_ << "\n";
cout << " area: " << r.Area() << " " << r.measurementUnit_ << "^2\n";
cout << " the rectangle " << (r.IsSquare() ? "is " : "is not ") << "a square.\n\n";
}
示例2: InclusiveArea
int InclusiveArea (Rectangle &r){
// I include it
if (r.topLeft.x >= topLeft.x && r.bottomRight.x <= bottomRight.x &&
r.topLeft.y <= topLeft.y && r.bottomRight.y >= bottomRight.y ) {
return this->Area();
}
// it includes me
if (r.topLeft.x <= topLeft.x && r.bottomRight.x >= bottomRight.x &&
r.topLeft.y >= topLeft.y && r.bottomRight.y <= bottomRight.y ) {
return r.Area();
}
// 0 - no inclusive
return 0;
}
示例3: Area
bool Rectangle::operator!=(const Rectangle& other) const
{
return Area()!=other.Area();
}
示例4: process
void process(Rectangle &r) {
int w = r.getWidth();
r.setHeight(10);
cout << "Expect area = " << (w*10) << ", got " << r.Area() << endl;
}