dimanche 3 février 2019

Why i cannot use constexpr global variable to initailize constexpr reference type

#include <iostream>
using namespace std;

constexpr int r =100;
int main()
{
    constexpr int &k = r ;
    cout << k << endl;
}

Compiling this code throws "error: binding ‘const int’ to reference of type ‘int&’ discards qualifiers" at compile time.

Aucun commentaire:

Enregistrer un commentaire