Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7025235
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:56:50+00:00 2026-05-27T23:56:50+00:00

I’m trying to learn c++ with wxWidgets. Till now all my programs were written

  • 0

I’m trying to learn c++ with wxWidgets. Till now all my programs were written in plain C (no needs for objects), vba, bash – as you see I’m not programer.

Even if this example is in frame of wxWidgets it’s general c++ problem (actually it’s mine problem with c++ 😉

The main windows has a menu-bar with sub-menu Settings/Communication.
I have defined a class that for a main frame in startup.h:

class startUp: public wxFrame
{    
    DECLARE_CLASS( startUp)
    DECLARE_EVENT_TABLE()
public:
    startUp();
    startUp( wxWindow* parent, wxWindowID id = SYMBOL_....
    ~startUp();
    void OnMENUCommunicationClick( wxCommandEvent& event );
    ....
    void SetDevName(const wxString& devname);
protected:
    static wxString devName;
};

and startup.cpp:

....
void startUp::SetDevName(const wxString& devname) 
{
    devName=_T(devname);
}

The OnMENUCommunicationClick calls a dialog that should return the name of the device selected in wxChoice (btw, feeding of the wxChoice works). This dialog defined in another class:

#include "startup.h"
class Communication: public wxFrame
{  
....
void Communication::CreateControls();
protected:
    wxArrayString portChoiceStrings;

communication.cpp:

...
void Communication::CreateControls()
    std::vector<std::string> ports;
    int count = ScanSerialPorts( ports, true );
    for( int i = 0; i < count; i++ ) {
       portChoiceStrings.Add( wxString( ports[ i ].c_str(), wxConvUTF8 ) );
    }
    portChoice = new wxChoice( itemPanel2, ID_ComportSet, wxPoint(108, 25), wxSize(55, -1), portChoiceStrings, 0 );
    portChoice->SetSelection(0);
....
}

void Communication::OnOKClick( wxCommandEvent& event )
{
    startUp::SetDevName(_T(portChoiceStrings[portChoice->GetSelection()]));
    //startUp::SetDevName(wxT(""));
    Destroy();
}

Now to my problem I hoped that OnOKClick would return to startUp selected device. What I’ve got is:
c2352 illegal call of non-static member function. As the member of startUp is not initialized my option was to change in startup.h both function and variable to static.

static void SetDevName(const wxString& devname);
static wxString devName;

The things improved – all files compile but linker says unresolved external symbol “protected: static class wxString startUp::devName”. Moving devName from protected to public doesn’t change a thing.

Can somebody explain me what is “the proper” way of passing values between classes? I wouldn’t like to use global variables to solve it. Apparently these are evil.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:56:51+00:00Added an answer on May 27, 2026 at 11:56 pm

    I’ve found solution. I’ve removed word static from definitions.

    In class startup after initialize of dialog window I’ve add a call to function setLink:

    void startUp::OnMENUCommunicationClick( wxCommandEvent& event )
        {
        Communication* window = new Communication(this,ID_COMMUNICATION, _("Communication Settings"));
        window->setLink(this);
        int returnValue = window->Show();
        }
    

    Than in class Communication I’ve added a link function setLink that stores pointer of main window:

    void Communication::setLink(startUp* papi)
        {
        this->m_link = papi;
        }
    

    which I could use in OnSetClick :

    void Communication::OnSetClick( wxCommandEvent& event )
        {
        m_link->SetDevName(_T(portChoiceStrings[portChoice->GetSelection()]));
        Destroy();
        }
    

    The m_link variable was defined in communication.h as a member of startUp class:

    startUp* m_relative;   
    

    Everything works (i.e. program compiles and links without errors and the devName variable from startUp-Frame is set to value read from Communication menu.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
I'm trying to create an if statement in PHP that prevents a single post

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.