fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. struct Point {
  5. int x;
  6. int y;
  7. };
  8.  
  9. int main() {
  10. Point p1 = {3, 4}; // declare and init members
  11. cout << "(" << p1.x << "," << p1.y << ")" << endl; // (3,4)
  12.  
  13. Point p2 = {}; // declare and init numbers to defaults
  14. cout << "(" << p2.x << "," << p2.y << ")" << endl; // (0,0)
  15. p2.x = 7;
  16. p2.y = 8;
  17. cout << "(" << p2.x << "," << p2.y << ")" << endl; // (7,8)
  18. return 0;
  19. }
  20.  
  21.  
Success #stdin #stdout 0.01s 5276KB
stdin
 
stdout
(3,4)
(0,0)
(7,8)