-編集-
迅速な対応のおかげで、コードに非常に奇妙な問題が発生し、キャストをdynamic_castに変更して、完全に機能するようになりました。
-元の投稿-
ある基本クラスのポインタを別の基本クラスにキャストしても安全ですか?これを少し拡張するために、次のコードでマークしたポインターは未定義の動作を引き起こしませんか?
class Base1
{
public:
// Functions Here
};
class Base2
{
public:
// Some other Functions here
};
class Derived: public Base1, public Base2
{
public:
// Functions
};
int main()
{
Base1* pointer1 = new Derived();
Base2* pointer2 = (Base2*)pointer1; // Will using this pointer result in any undefined behavior?
return 1;
}