Let\'s say we have a class called object.
int main(){
object a;
const object* b = &a;
(*b);
}
Question: b is a pointer to
The type of an expression is just based on the declared types of the variables in the expression, it can't depend on dynamic run-time data. For instance, you could write:
object a1;
const object a2;
const object *b;
if (rand() % 2 == 0) {
b = &a1;
} else {
b = &a2;
}
(*b);
The type of *b
is determined at compile-time, it can't depend on what rand()
returns when you run the program.
Since b
is declared to point to const object
, that's what the type of *b
is.