Anfänger Frage



  • Hallo ich habe ein Problem, weiss nicht genau wonach ich da suchen soll und was ich falsch mache, was ich so finde bei google und so, sagt ich mach es richtig...

    public: static_objekt(float radius, float eigenrotation, float x, float y)
    {
        this->radius = radius;
        this->eigenrotation = eigenrotation;
        this->x = x;
        this->y = y;
    
    }
    public: static_objekt(){};
    public:
    void position()
    {
        glTranslatef(x,y,0);
    
    }
    
    void rotation()
    {
        glRotatef(this->zeit,0,0,1);
    }
    void transform()
    {
        this->position();
        this->rotation();
    
    }
    void zeichnen()
    {
        this->transform();
        glutWireSphere(this->radius, 30, 30);
    
    }
    
    public: void next(long zeit)
    {
    
        this->zeit = zeit;
        this->zeichnen();
    
    }
    
    class rotate_objekt :public static_objekt
    {
    float radius;
    float eigenrotation;
    float umlauf;
    float abstand;
    float ellipse;
    static_objekt* travon;
    public: rotate_objekt(float radius, float eigenrotation, float umlauf, float abstand, float ellipse, static_objekt* travon):static_objekt()
    {
        this->radius = radius;
        this->eigenrotation = eigenrotation;
        this->umlauf = umlauf;
        this->abstand = abstand;
        this->ellipse = ellipse;
        this->travon = travon;
    
    }
    
    void position()
    {
            glTranslatef(-3,-4,0);
    }
    
    };
    

    ich will, dass rotate objekt von static objekt erbt, und die funktionen nutzen kann. aber void position() soll er neu definieren....
    hoffe ich drücke mich verständlich aus.

    kann mir jemand helfen?



  • Sowas?

    class StaticObject
    {
    public:
      virtual ~StaticObject() {}
    
      // ...
    
      virtual void Position() {}
    }
    
    class RotatedObject : public StaticObject
    {
    public:
      /*virtual*/ void Position()
      {
        // hier die spezielle implementierung
      }
    };
    


  • ahh ^^ irgendwie tuts jetzt...
    danke


Anmelden zum Antworten