親クラス:
template <class T>
class Point
{
protected
T x;
T y;
};
派生クラス:
template <class T>
class Point3DTopo: public Point <T>
{
protected:
T z;
Face <T> *face; //Points to any face
};
クラスPointsListの1つのオブジェクトを別のオブジェクトPoints3DTopoListにキャストしたいと思います(またはその逆)。
template <class T>
class PointsList
{
protected:
std::vector <Point <T> *> points; //Only illustration, not possible with templaes
};
template <class T>
class Points3DTopoList
{
protected:
std::vector <Point3DTopo <T> *> points; //Only illustration, not possible with templaes
};
そのような変換は許可されていますか?
Points3DTopoList <T> *pl = new Points3DTopoList <T> ();
...
PointsList <T> *pl = reinterpret_cast < PointsList <T> * > ( pl3D );
そして逆変換?
PointsTopoList <T> *pl = new PointsTopoList <T> ();
...
Points3DTopoList <T> *pl3D = reinterpret_cast < Points3DTopoList <T> * > ( pl );
各Point3TopoのFaceポインターは、NULLに初期化されますか、それとも未定義になりますか?