1

Builder6を使用しています。

バグを修正する方法がわかりません:

[C++ Error] loltimer.cpp(11): E2316 '_fastcall TForm1::TForm1(TComponent *)' is not a member of 'TForm1'
[C++ Error] loltimer.cpp(18): E2062 Invalid indirection

私の .cpp コード:

// line 11
__fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner)
{
    comboSpell(ComboBox1);
}
//---------------------------------------------------------------------------

void TForm1::comboSpell(TComboBox *combo){
    // line 18
    *combo ->Items->Add("Flash");
    *combo ->Items->Add("Ignite");
    *combo ->Items->Add("Exhaust");
    *combo ->Items->Add("Teleport");
    *combo ->Items->Add("Ghost");
    *combo ->Items->Add("Heal");
    *combo ->Items->Add("Smite");
    *combo ->Items->Add("Barrier");
} 

私の .h コード:

public:     // User declarations
    __fastcall TForm1(TComponent Owner);
    void comboSpell(TComboBox *combo);
4

2 に答える 2

2

[C++ エラー] loltimer.cpp(11): E2316 '_fastcall TForm1::TForm1(TComponent *)' は 'TForm1' のメンバーではありません

コンストラクターの宣言はTForm()、.h コードと .cpp コード、特にOwnerパラメーターで異なります。それらは一致する必要があります:

public:     // User declarations
    __fastcall TForm1(TComponent *Owner);

__fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
{
    ...
}

[C++ エラー] loltimer.cpp(18): E2062 インダイレクションが無効です

combo演算子を使用してポインターを逆参照し*てから、演算子で再度逆参照してい->ます。この場合、それは機能しません。次のいずれかを行う必要があります。

  1. ->演算子を単独で使用します (典型的な使用法):

    combo->Items->Add("Flash");
    
  2. .演算子の代わりに演算子を使用し->ます (一般的ではありません)。

    (*combo).Items->Add("Flash");
    
于 2013-12-29T05:13:07.617 に答える