this is because you are trying to convert from int** to const int**
int ** v = new int * [10];
int ** : "pointer to a pointer to an integer".const int ** : "pointer to a pointer to a constant integer".
Using const is a contract, and you cannot execute this contract by clicking on the link to two links.
From the standard:
const char c = 'c'; char* pc; const char** pcc = &pc;
so one could change const char always , just use the procedure above.
And:
char *s1 = 0; const char *s2 = s1;
nice cite at the link below:
Similarly, if you hide a criminal under a legitimate disguise, he can then use the trust given to that disguise. This is bad.
http://www.parashift.com/c++-faq-lite/constptrptr-conversion.html
related to this is also an invalid Derived** → Base** conversion. If it would be legal to convert Derived** → Base** , Base** could be dereferenced (by receiving Base* ), and Base * could be pointed to an object of another derived class, which could cause serious problems. See why:
class Vehicle { public: virtual ~Vehicle() { } virtual void startEngine() = 0; }; class Car : public Vehicle { public: virtual void startEngine(); virtual void openGasCap(); }; class NuclearSubmarine : public Vehicle { public: virtual void startEngine(); virtual void fireNuclearMissle(); }; int main() { Car car; Car* carPtr = &car; Car** carPtrPtr = &carPtr; Vehicle** vehiclePtrPtr = carPtrPtr;
http://www.parashift.com/c++-faq-lite/derivedptrptr-to-baseptrptr.html
consider the following issues:
class Vehicle { public: virtual ~Vehicle() { } virtual void startEngine() = 0; }; class Car : public Vehicle { public: virtual void startEngine(){printf("Car engine brummm\n");} virtual void openGasCap(){printf("Car: open gas cap\n");} virtual void openGasCap2(){printf("Car: open gas cap2\n");} virtual void openGasCap3(){printf("Car: open gas cap3\n");} virtual void openGasCap4(){printf("Car: open gas cap4\n");} }; class NuclearSubmarine : public Vehicle { public: int i; virtual void startEngine(){printf("Nuclear submarine engine brummm\n");} virtual void fireNuclearMissle3(){printf("Nuclear submarine: fire the missle3!\n");} virtual void fireNuclearMissle(){printf("Nuclear submarine: fire the missle!\n");} virtual void fireNuclearMissle2(){printf("Nuclear submarine: fire the missle2!\n");} }; int main(){ Car car; Car* carPtr = &car; Car** carPtrPtr = &carPtr;