lundi 29 juin 2015

global declarations/initializations using static, const, constexpr

In C++ or C++11, for the following declarations//initializations,

// global scope
const int a = 1; // line 1
static const int b = 2; // line 2
constexpr int c = 3;  // line 3
static constexpr int d = 4; // line 4
constexpr int e = a + b + c*d; // line 5
static cosntexpr int f = a - b - c*d; // line 6

This question says at file scope there is no difference between line 1 and 2 in C++. How about line 3 and 4?

Are there differences between line 4 and 5?

Are there differences between line 5 and 6?

Aucun commentaire:

Enregistrer un commentaire