C ++ - Vererbungs-Downcasting
Ich habe meine Basisklasse wie folgt:
class point //concrete class
{
... //implementation
}
class subpoint : public point //concrete class
{
... //implementation
}
Wie kann ich ein Punktobjekt in ein Unterpunktobjekt umwandeln? Ich habe alle drei der folgenden versucht:
point a;
subpoint* b = dynamic_cast<subpoint*>(&a);
subpoint* b = (subpoint*)a;
subpoint b = (subpoint)a;
Was ist los mit diesen Darstellern?