CRect rect1(10, 20, 50, 60); int width = rect1.Width();
#include#include using namespace std; int main() { vector rects; rects.push_back(CRect(10, 20, 50, 60)); rects.push_back(CRect(30, 40, 80, 90)); rects.push_back(CRect(100, 200, 300, 400)); for (int i = 0; i < rects.size(); i++) { int width = rects[i].Width(); cout << "Rectangle " << i+1 << " width is: " << width << "\n"; } return 0; }
Rectangle 1 width is: 40 Rectangle 2 width is: 50 Rectangle 3 width is: 200The package library used for this example is MFC (Microsoft Foundation Class) in C++.