axeljaeger
04-07-2004, 16:04
Ich habe ein Objekt Curve
class Curve {
public:
void movePoint(const PointList::iterator & p,
double nx, double ny);
void removePoint(const PointList::iterator & p);
protected:
virtual void pointAdded(const Point& ) {}
virtual void pointRemoved(const Point& ) {}
private:
...
}
Dann hab ich noch ein zweites Object Curve Model
class CurveModel : public Curve {
protected:
void pointAdded(const Point&);
void pointRemoved(const Point&);
void pointMoved(const Point&);
};
Ich mache damit öfters solche Sachen:
CurveModel* cm;
Curve c = *cm;
Darf ich das, so lange ich die virtuals nicht aufrufen möchte? Es funktioniert zwar, aber bei C++ weis man nie, ob das jetzt nur zufällig so funktioniert. Mittlerweile kommt es mir sehr abenteuerlich vor. Sollte ich mein Design ändern?
class Curve {
public:
void movePoint(const PointList::iterator & p,
double nx, double ny);
void removePoint(const PointList::iterator & p);
protected:
virtual void pointAdded(const Point& ) {}
virtual void pointRemoved(const Point& ) {}
private:
...
}
Dann hab ich noch ein zweites Object Curve Model
class CurveModel : public Curve {
protected:
void pointAdded(const Point&);
void pointRemoved(const Point&);
void pointMoved(const Point&);
};
Ich mache damit öfters solche Sachen:
CurveModel* cm;
Curve c = *cm;
Darf ich das, so lange ich die virtuals nicht aufrufen möchte? Es funktioniert zwar, aber bei C++ weis man nie, ob das jetzt nur zufällig so funktioniert. Mittlerweile kommt es mir sehr abenteuerlich vor. Sollte ich mein Design ändern?