Code:
typedef _jobject* jobject;
typedef _jarray* jarray;
Stuff like that drives you mad when reading others code. Don't do it.
Use proper types instead:
Code:
class _jobject {};
class _jarray : public _jobject {};
int main()
{
_jobject** a;
_jarray* b;
a = dynamic_cast<_jobject**> (&b);
....
}
And from what I understand, you cannot implicitly convert a pointer to pointer of a derived class to base.
This also fails:
Code:
class _jobject {};
class _jarray : public _jobject {};
int main()
{
_jobject** a;
_jarray* b;
a = &b;
....
}
To get around it, you can use an explicit C-style cast or a static cast to get it to compile:
Code:
class _jobject {};
class _jarray : public _jobject {};
int main()
{
_jobject** a;
_jarray* b;
a = static_cast<_jobject**> (&b);
....
}
But, perhaps better is to convert the derived pointer to a base pointer first and then assign its address to the base object pointer:
Code:
class jobject {};
class jarray : public jobject {};
int main()
{
jobject** a;
jarray* b;
jobject* temp = b;
a = &temp;
return 0;
}