I
Igor R.
Hello,
I've got the following code:
int main()
{
const extern int &ref;
{
int var = 5;
const int &ref = var;
}
int var = ref;
}
I.e., I'd like to define and initialize a const ref in a local scope,
but want to *declare* and to be able to use it in the outer scope. I
attempt to declare it as extern, but this doesn't link well, i.e.
"const int &ref = var;" isn't interpreted as the above extern
definition, but as another local variable.
Is it possible to do the above trick somehow? (I know I can
restructure the code as the last resort.)
Thanks.
I've got the following code:
int main()
{
const extern int &ref;
{
int var = 5;
const int &ref = var;
}
int var = ref;
}
I.e., I'd like to define and initialize a const ref in a local scope,
but want to *declare* and to be able to use it in the outer scope. I
attempt to declare it as extern, but this doesn't link well, i.e.
"const int &ref = var;" isn't interpreted as the above extern
definition, but as another local variable.
Is it possible to do the above trick somehow? (I know I can
restructure the code as the last resort.)
Thanks.