vendredi 29 avril 2016

Explain pair function in C++

I encountered this code

#define pii pair<int, int>
#define pip pair<int, pii>

...

vector< pip > graph;
graph[i] = pip( c, pii(u,v));

When I try

graph[i] = pair<c,pair<u,v>>;

I get an error message

error: 'c' cannot appear in a constant-expression 
error: 'i' cannot appear in a constant-expression
error: 'j' cannot appear in a constant-expression

Why are these two expressions not equal?

Aucun commentaire:

Enregistrer un commentaire