If you are using the main C++ distribution of wxWidgets, Feel free to ask any question related to wxWidgets development here. This means questions regarding to C++ and wxWidgets, not compile problems.
omahdezavalos
In need of some credit
Posts: 7 Joined: Mon Jan 07, 2019 9:40 pm
Post
by omahdezavalos » Tue Jan 08, 2019 5:40 am
I want to create a function and calculate the transformation from mm to thousands of the inches, like...declare in Main.h and defined in main.cpp
double convert(double dim)
{
return (dim * 39.37);
}
then if I try to do:
conv<<convert(d_mm);
give an error undefined reference to TESTFrame::convert(double),
error: ld returned 1 exit status
if I kept conv<<d_mm * 3937 it work
void TESTFrame::OnButton2Click(wxCommandEvent& event)
{
double d_mm = 0.0;
wxString conv = wxT("");
if(TextCtrl4->GetValue().ToDouble((&d_mm)))
{
conv<<d_mm * 39.3700787401575; //code to become a function.................. conv<<convert( d_mm); //trow an error
TextCtrl5->SetValue(conv);
}
else{
wxMessageBox((wxT("There is a error OnButton2Click .....")));
}
}
doublemax
Moderator
Posts: 19163 Joined: Fri Apr 21, 2006 8:03 pm
Location: $FCE2
Post
by doublemax » Tue Jan 08, 2019 6:22 am
Please show the definition and declaration of that function in context.
From the error message it looks like you declared "convert" as a class method for TESTFrame, but you defined it in global scope.
If you intended to make it a class method, it should look like this:
Code: Select all
double TESTFrame::convert(double dim)
{
return (dim * 39.37);
}
Use the source, Luke!
omahdezavalos
In need of some credit
Posts: 7 Joined: Mon Jan 07, 2019 9:40 pm
Post
by omahdezavalos » Wed Jan 09, 2019 4:46 am
Wow, you are right in the debugging genius category, that was really good.