Are temporaries const? Pass by const reference

46 Views Asked by At
#include <iostream>
using namespace std;

void f(const int& x)
{
}

int g()
{
    int x = 0;
    return x;
}

int main() {
    f(g());
} 

If i remove the const from f it doesnt work; What does this mean, is the temporary returned from g a const???

0

There are 0 best solutions below