#Need help with C++ pairs

14 messages · Page 1 of 1 (latest)

wind verge
#

So, was learning STL and started off with learning pairs.
my code :-

#include <iostream>
#include <utility>
using namespace std;

int main() {
    pair<int, int> p = {1, 3};
    
    cout << p.second;
    
    return 0;
}

in the video I saw, it was working correctly for him.

but in my case this error shows up while compilin - 6 29 C:\Users\ASUS\Documents\C++\vectors.cpp [Error] in C++98 'p' must be initialized by constructor, not by '{...}'

#

this worked with -

    pair<int, int> p;
    p.first = 1;
    p.second = 3;
#

but I still wanna know

#

why it showed that error

gentle wigeon
wind verge
#

ok Thanks!

wind verge
wind verge
#

@limber root

limber root
#

Why am I pinged here?

wind verge
#

can you help

limber root
#

I can't

wind verge
#

and sorry

gentle wigeon