int如何成为AssetManager?

时间:2011-04-02 08:01:17

标签: c++

为什么这样做?

AssetManager* am = (AssetManager*)env->GetIntField(obj, gAssetManagerOffsets.mObject);  

env->env->GetIntField()会返回Int。为什么可以将其转换为AssetManager?此代码来自文件android_util_AssetManager.cpp

1 个答案:

答案 0 :(得分:2)

返回的int是指向AssetManager的指针。 (AssetManager*)告诉您它是指向AssetManager的指针。

所以,它返回一个int,它恰好是一个指向AssetManager的指针。它没有返回AssetManager。

Tutorial on Arrays and Pointers in C可能会对您有所帮助。第5章显示了您在所提到的代码中看到的语法。