#include#include // SFML library for graphics int main() { sf::Rect rect(0, 0, 100, 50); // Create a Rect object with (x,y) position (0,0) and width=100, height=50 std::cout << "Rect width: " << rect.width << std::endl; // Output the width of the Rect object return 0; }
Rect width: 100
#include#include // SDL library for graphics int main() { SDL_Rect rect = { 0, 0, 100, 50 }; // Create a Rect object with (x,y) position (0,0) and width=100, height=50 std::cout << "Rect width (before): " << rect.w << std::endl; rect.w = 200; // Change the width of the Rect object to 200 std::cout << "Rect width (after): " << rect.w << std::endl; return 0; }
Rect width (before): 100 Rect width (after): 200In this example, we create a Rect object using the SDL library and set its position and size. We then change the width of the object using the `w` member variable and output the new width. Package/library: SDL (Simple DirectMedia Layer)