Question

I'm using Builder 6.

Have no idea how to fix bugs:

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

My .cpp code:

// 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");
} 

My .h code:

public:     // User declarations
    __fastcall TForm1(TComponent Owner);
    void comboSpell(TComboBox *combo);
Was it helpful?

Solution 2

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

The declaration of your TForm() constructor is different in your .h and .cpp code, specifically in the Owner parameter. They need to match:

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

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

[C++ Error] loltimer.cpp(18): E2062 Invalid indirection

You are dereferencing the combo pointer using the * operator and then dereferencing it again with the -> operator. That will not work in this case. You need to either:

  1. Use the -> operator by itself (the typical usage):

    combo->Items->Add("Flash");
    
  2. Use the . operator instead of the -> operator (not typical):

    (*combo).Items->Add("Flash");
    

OTHER TIPS

The header has the parameter as TComponent and the .cpp has it as TComponent *. You need them to be the same.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top