Getting variable value & error E2288

Dear Reader,

I am writing a application in Builder v.6 using few Standard objects like Buttons and MainMenu.

I have following problem.

When in object TForm2::Wspolczynnikikanaludopliku1Click I want to get the value of variable drop_number declared and definited in object TForm2::Button1Click I get fallowing error:

[C++ Error] fMIMO_channel.cpp(279): E2288 Pointer to structure required on left side of -> or ->*
.

Bellow I attached source code:

1
2
3
4
5
6
7
void __fastcall TForm2::Button1Click(TObject *Sender)
{
int drop_number; 
....
drop_number=Edit8->Text.ToInt();
....
}


1
2
3
4
5
6
7
void __fastcall TForm2::Wspolczynnikikanaludopliku1Click(TObject *Sender)
{
 int liczba_D;
...
 liczba_D=Button1Click->drop_number;
...
}


Maybe someone knows how to rewrite this code to work correct?


The -> operator doesn't do what you seem to think.

You can't get a variable from another function like that. Typically you'd have the function return a value and call the function in order to get the value. But since "Button1Click" seems like a function that is triggered by a GUI event (a button click perhaps? =P) I'm guessing that solution won't work here.

What you can do is instead of putting drop_number in Button1Click, you can put it in TForm2:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
class TForm2
{
...
  int drop_number;
...
};

//-----------------------------

void __fastcall TForm2::Button1Click(TObject *Sender)
{
// don't do int drop_number here
...
  drop_number = /*whatever*/;
}

//------------------------

void __fastcall TForm2::Wspolczynnikikanaludopliku1Click(TObject *Sender)
{
 int liczba_D;
...
 liczba_D = drop_number;
}


Whether or not this is really a good solution is another matter, though. I don't really have an idea of what the big picture is here. Something tells me there's something deeper that's wrong with your program logic -- and this tweak might not work.
Topic archived. No new replies allowed.