Vererbung von Klassen -> Konstructor
-
Hey also hier mein Problem:
Ich zeichne normale Tasten mit einer Klasse bei denen Parameter im Konstruktor übergeben werden sollen. jetzt möchte ich noch spezielle Tasten einbauen. Also benutze ich eine abgeleitete Klasse. Nur irgendwie kommt immer die Fehlermeldung "Kein geeigneter Standtartkonstruktor". Ich habe schon alles versucht.#pragma once #include "Textur.h" class CKey { public: CKey(int kk,float rr,float gg,float bb, char cc, char *f); virtual ~CKey(void); CTextur *textur; void draw(); float width,height; char character; char *file; float r,g,b; int key; private: virtual void _draw(); void init(); bool setup; }; class CspaceKey : public CKey { public: CspaceKey(int kk,float rr,float gg,float bb, char cc, char *f); virtual ~CspaceKey(void); void _draw(); };das ist mein Kopf
#include "Key.h" #include <stdlib.h> #include "glut.h" CKey::CKey(int kk,float rr,float gg,float bb, char cc,char *f) { key = kk; r = rr; g = gg; b = bb; width = 1.0/12; height = 1.0/5; character = cc; file = f; setup = true; } CKey::~CKey(void) { } void CKey::init() { textur = new CTextur(); textur->load(file); } void CKey::draw() { if(setup) { init(); setup = false; } if(key == 1) { glColor3f(r,g,b); glPushMatrix(); textur->bind(); glBegin(GL_QUADS); glVertex2f(0,0); glVertex2f(0,height); glVertex2f(width,height); glVertex2f(width,0); glEnd(); textur->unbind(); glPopMatrix(); glTranslatef(width,0,0.0f); } else if(key == 2) { this->_draw(); } } void CKey::_draw() { } CspaceKey::CspaceKey(int kk,float rr,float gg,float bb, char cc,char *f) //: CKey(kk) etc. auch versucht aber keinen Erfolg { } CspaceKey::~CspaceKey(void) { } void CspaceKey::_draw() { glColor3f(r,g,b); glPushMatrix(); textur->bind(); glBegin(GL_QUADS); glVertex2f(0,0); glVertex2f(0,height); glVertex2f(width,height); glVertex2f(width,0); glEnd(); textur->unbind(); glPopMatrix(); glTranslatef(width,0,0.0f); }
-
Du mußt beim Konstruktor den passenden Basisklassen-Konstruktor aufrufen:
CspaceKey::CspaceKey(int kk,float rr,float gg,float bb, char cc,char *f) : CKey(kk, rr, gg, bb, cc, f) { }
-
oh man ich bin so blöd^^
aber danke für deine Hilfe
