jeudi 30 avril 2020

Strange behaviour of variable in c++

I am unable to understand how a variable defined in an outer scope can be redefined in an inner scope.

Here is my sample code. The code compiles successfully.

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

#define ll long long int

int main(int argc, char const *argv[])
{
    ll t;
    cin>>t;
    while(t--)
    {
        map<ll,ll> mp;
        map<ll,ll>::iterator t=mp.end();
    }
    return 0;
}

Aucun commentaire:

Enregistrer un commentaire