-1

I am working a lot with pairs in c++ these days so I want to do next:

Instead of:

pair<int, int> p;
cin >> p.first >> p.second;

I want to write:

pair<int, int> p;
cin >> p.x >> p.y;

I tried #define first x and similar things but it doesn't work. How to redefine this?

1 Answers1

0

Just define your own template struct with x and y members. Just like std::pair, just with different member names. Then use your own struct instead of std::pair.

Jesper Juhl
  • 30,449
  • 3
  • 47
  • 70