BRect rect1(10, 10, 50, 50); BRect rect2(30, 30, 70, 70); if (rect1.Intersects(rect2)) { cout << "Rectangles intersect!" << endl; } else { cout << "Rectangles do not intersect." << endl; }
vectorIn this example, we have a vector of rectangles and a single rectangle (rect). We loop through the vector and check whether each rectangle intersects with rect using the Intersects method. If there is an intersection, we output a message. These examples use the BRect class from the Be API, which is a library for developing applications on the BeOS operating system.rects = {...}; // a vector of rectangles BRect rect(0, 0, 100, 100); for (auto r : rects) { if (r.Intersects(rect)) { cout << "Rectangle " << r << " intersects with " << rect << endl; } }