c++ - Allocating an object of abstract class type when trying to create a SceneNode -
i have issue don't manage solve in c++.
i have class called scenenode. in class, there isn't virtual function , in private members, have vector of unique_ptr , raw pointer scenenode object. when try allocate new scenenode, following error: allocating object of abstract class type "scenenode".
here's code:
class scenenode : public sf::drawable, public sf::transformable, private sf::noncopyable { //overview: scenenode node scene graph. represents graphical element //a typical scenenode (parent, children, transform) //with transform containing several information: //transform.pos = position of //transform.rotation = rotation of //the transformation of relative parent //therefore, transform.pos position of this, relatively parent //nb: - scenenode not copyable ! // - it's abstract class public: //-------------------------------------------- //typedefs //-------------------------------------------- typedef std::unique_ptr<scenenode> uniqueptr; typedef sf::vector2f position; public: //-------------------------------------------- //constructors //-------------------------------------------- scenenode(); //requires: / //modifies: //effects: initializes this_post.parent = no parent // , this.children = { ⦰ } public: //-------------------------------------------- //public member functions //-------------------------------------------- void attachchild(uniqueptr child); //requires: child != nullptr //modifies: //effects: if child == nullptr, stops program; // else, this_post.children = this.children u { child } uniqueptr detachchild(const scenenode& child); //requires: / //modifies: //effects: if child in this.children, this_post.children = this.children \ child && returns unique_ptr child, don't catch let being freed sf::transform getworldtransform() const; //requires: / //modifies: / //effects: returns absolute transformation of position getworldposition() const; //requires: / //modifies: / //effects: returns absolute position of private: //-------------------------------------------- //representation //-------------------------------------------- scenenode* mparent; std::vector<uniqueptr> mchildren; };`
what can ? in advance
it appears inheriting abstract interfaces sf::drawable not implementing pure virtual functions define (the draw() function in case of drawable). if implement functions in class should rid of compiler errors.
Comments
Post a Comment