Wie kann man von TPaintBox erben?
-
hallo zusammen
ich möchte folgendes erreichen, eine Klasse spielfeld (field) die von TPaintBox erbt, aber leider erhalte ich immer die Fehlermeldung[C++ Fehler] field.h(16): E2113 Virtuelle Funktion 'Field::Field(TComponent *)' verursacht Konflikte mit der Basisklasse 'TPaintBox'
was mache ich da falsch, könnte ein trivialer fehler sein, denn ich bin blutiger anfänger. vielen dank für hinweise
//---------------------------------------------------------------------------
#ifndef fieldH
#define fieldH
//---------------------------------------------------------------------------
#endif
#include <vcl.h>
#include <ExtCtrls.hpp>class Field : public TPaintBox{
private:
int x1;
int y1;
int x2;
int y2;
public:
Field(TComponent *AOwner);
};#pragma hdrstop
#include "field.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)Field::Field(TComponent* AOwner):
TPaintBox(AOwner)
{
x1 = 10;
y1 = 10;
x2 = 100;
y2 = 100;
this->Left = x1;
this->Top = y1;
this->Width = (x2 - x1);
this->Height = (y2 - y1);
this->Color = clBlue;
this->Canvas->Rectangle(1,1,50,50);
this->Refresh();
}
-
Sieh dir mal die sonst übliche Deklaration des Konstruktors von VCL-Klassen an, z.B. den in einer Form-Unit.
-
Jansen schrieb:
Sieh dir mal die sonst übliche Deklaration des Konstruktors von VCL-Klassen an, z.B. den in einer Form-Unit.
Declaration:
TForm1(TComponent* Owner);Implementation:
TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{