Structs

8.3 - Member access


The members of an object can be accessed with the dot operator . .

This code prints out x of point_e:

Point point_e{5, -2};
std::cout << point_e.x << std::endl; // Prints out 5.

Task

Print out the x and y coordinate of the point_a and point_b variable in the format (x, y) in one line each:

- Print out `point_a.x` and `point_a.y`
- Print out `point_b.x` and `point_b.y`
#include <iostream> struct Point { int x; int y; }; int main() { Point point_a{3, 4}; Point point_b{-2, -3}; }