-1

I got two forms (form_1 and form_2). I made a function inside body of form_1.

void ExampleFunction() {
    ShowMessage("I'm example function inside form_1");
}

and I want to call it from form_2.

I tryed to add this function to header file of form_1.

public: // User declarations
    __fastcall Tform_2(TComponent* Owner);
    void ExampleFunction();
};

but when I want to call it from form_2, like :

form_2->ExampleFunction();

Builder gives me a error : "[ilink32 Error] Error: Unresolved external"

So how can I do it properly to make it work ?

M.M
  • 138,810
  • 21
  • 208
  • 365
  • There's a lot of cases go to through in that "dupe"... might be pretty scary for a beginner – M.M May 25 '14 at 00:26

1 Answers1

2

You are contradicting yourself. You said you want to implement the function in Form_1 and call it from Form_2, but you are trying to implement it in Form_2 and call it from outside of Form_2.

In any case, you declared the function as a member of the Tform_2 class, so you need to qualify the function's body as such:

void Tform_2::ExampleFunction() {
    ShowMessage("I'm example function inside form_1");
}
Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770