#include#include int main() { BRect rect(10, 10, 50, 50); // create a square BRect BRect newRect = rect.OffsetToCopy(60, 60); // offset the BRect by (50, 50) std::cout << "Original BRect: " << rect.left << "," << rect.top << " - " << rect.right << "," << rect.bottom << std::endl; std::cout << "New BRect: " << newRect.left << "," << newRect.top << " - " << newRect.right << "," << newRect.bottom << std::endl; return 0; }
#includeThis example uses the OffsetToCopy function to create a new BRect object that is offset by (50, 50) from the original one. It then passes both the original and new BRect objects to a function called drawRect, which draws a rectangle at the given coordinates using graphics programming tools. The program will draw the original rectangle at its original position, and a copy of the rectangle at (60, 60). This function is part of the BeOS/Haiku API library.void drawRect(BRect rect) { // code to draw a rectangle at the given coordinates } int main() { BRect rect(10, 10, 50, 50); // create a square BRect drawRect(rect); // draw the rectangle at its original position drawRect(rect.OffsetToCopy(60, 60)); // draw a copy of the rectangle at (60, 60) return 0; }