Hallo versuchte, eine einfache Verbund zu tun, und ich mit einem Fehler habe Schwierigkeiten bei dem Versuch, für die Ausbildung eines compenent des Verbund hinzuzufügenComposite-in C++ Fehlern [keine passende Elementfunktion callto ‚push_back‘]
Hier ist die Code
Component-Schnittstelle Inteface zum zeichnen von Verbund
class ObjectInterface
{
public:
ObjectInterface() {}
virtual void draw()=0;
virtual void applyTranslation(float x,float y){}
virtual void applyRotationDirect(float angle){}
virtual void applyRotationIndirect(float angle){}
virtual void applyHomethety(float ratio){}
virtual void applyAxialSymmetry(){}
virtual void applyCentralSymmetry(){}
};
Ein Element - Linie
class Line : public ObjectInterface,Object2D
{
public:
Line(string color,Point p1,Point p2);
// Inherited method from Object2D
float getArea();
float getPerimeter();
// Inherited method from ObjectInterface
virtual void draw();
void applyTranslation(float x,float y);
void applyRotationDirect(float angle);
void applyRotationIndirect(float angle);
void applyHomethety(float ratio);
void applyAxialSymmetry();
void applyCentralSymmetry();
friend ostream& operator<< (ostream &os, const Line &p);
};
class Fresque : public ObjectInterface
{
public:
Fresque();
// Inherited method from ObjectInterface
void draw();
void applyTranslation(float x,float y);
void applyRotationDirect(float angle);
void applyRotationIndirect(float angle);
void applyHomethety(float ratio);
void applyAxialSymmetry();
void applyCentralSymmetry();
// Personal method
bool add(ObjectInterface const &o);
bool remove(ObjectInterface const& o);
private:
std::vector<ObjectInterface*> objects; // CONTAINER FOR COMPOSITE
};
CPP-Datei für das Add-Methode
bool Fresque::add(ObjectInterface const & o){
objects.push_back(o); //===> THE ERROR HERE
return true;
}
der Fehler:
/fresque.cpp:50: erreur: kein Anpassungselement Funktion für den Aufruf von 'push_back' Objekte.push_back (o); ~~~~~~~~^~~~~~~~~
Die IDE ist QT, ich fühle mich schlecht, nicht zu wissen, wo der Fehler ist, und ich bin ziemlich sicher, dass es offensichtlich, dass ein: /.
Pointers = Referenzen – emlai