我必須爲我的OOP課程在C-builder中製作一個國際象棋程序。 (面向對象編程)C++ Builder - Piece.cpp(20):E2316'Button1Click'不是'TForm'的成員
我做了一個類Piece,並在這個類中創建了一個TImage imPiece。現在我想用一個來自主類的函數爲這個圖像分配一個Event OnClick。
Piece.cpp
Piece::Piece(unsigned int, unsigned int, TForm* fJoc)
{
imPiece = new TImage(fJoc);
imPiece -> Parent = fJoc;
imPiece -> Stretch = true;
imPiece -> Transparent = true;
imPiece -> Visible = true;
imPiece -> Width = 36;
imPiece -> Height = 36;
imPiece -> OnClick = fJoc -> Move;
}
Piece::~Piece(){}
formaJoc.cpp
void __fastcall TfJoc::Move(TObject *Sender)
{
exit(0);
}
formaJoc.h
class TfJoc : public TForm
{
/* ... not quoted parts of class declaration */
void __fastcall Move(TObject *Sender);
/* ... not quoted parts of class declaration */
};
錯誤:
[C++ Error] Piece.cpp(20): E2316 'Move' is not a member of 'TForm'
請勿將圖像或鏈接發佈到圖像。發佈實際的代碼和實際的錯誤消息。有關錯誤消息的內容尚不清楚? Tform沒有這樣的成員。 – Unimportant
請不要在評論中發佈代碼。 **編輯**你的文章的代碼。 –
@ user1320881我想從我創建的類創建一個TImage事件,並使用c-builder類中的函數。 –