Salut essayer de faire un simple composite et je suis aux prises avec une erreur lors d'une tentative d'ajouter un compenent au composite pour la formationComposite en C++ erreur [pas de fonction de membre correspondant à CALLTO « push_back »]
Voici la Code
l'interface de composant Inteface pour le dessin composite
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(){}
};
Un élément - ligne
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
};
fichier cpp pour la méthode add
bool Fresque::add(ObjectInterface const & o){
objects.push_back(o); //===> THE ERROR HERE
return true;
}
l'erreur:
/fresque.cpp:50: erreur: aucun membre correspondant fonction pour appel à 'push_back' objects.push_back (o); L'IDE est QT, je me sens mal de ne pas savoir où est l'erreur et je suis sûr que c'est une évidence:////////////////////////////////////.
Pointeurs = références – emlai