1

What is the point in returning a value as const?

const int getNum () {return 5}

And why can you return a variable that is not specified as const and also assign the returned value to a non-const variable? You can do this:

const int getNum ()
{
int z = 222;
return z; //hmm shouldn't z be specified as const in order for this to be valid?
}

and you assign it to a non-const variable:

int q = getNum();

Thanks!

0 Answers0