Trying to get the pointer compatibility straight. Here's a code sample demonstrating the thing I'm finding hard to comprehend:
struct T
{
int dummy;
};
int main(int argc, const char * argv[])
{
T t;
const T* cpt = &t; //Ok.
const T** ppct = &cpt; //Ok.
T* pt = &t;
const T** ppct2 =&pt;
//The line above gives me
//Cannot initialize a variable of type
//'const T **' with an rvalue of type 'T **'
return 0;
}
Before the return statement I'm trying to get the address of pointer to T, and assign it to the pointer to pointer to const T. What can go wrong, right? I won't be able to change the object I'm pointing to, but I'm not allowed to do this assignment.