使 mysqlpp::Connection 对象成为 wxFrame class 对象的私有成员

Make mysqlpp::Connection object private member of wxFrame class object

我在尝试构建将 mysqlpp::Connection 对象作为我的 wxFrame 对象的私有成员的代码时遇到错误。

class MyFrame: public wxFrame
{
    public:
        MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
    private:
        mysqlpp::Connection conn(false);


        wxDECLARE_EVENT_TABLE();        
};

G++ 给出以下错误。

C:\TestApp\testapp.cpp:31:28: error: expected identifier before 'false'
   mysqlpp::Connection conn(false);
                        ^
C:\TestApp\testapp.cpp:31:28: error: expected ',' or '...' before 'false'
C:\TestApp\testapp.cpp: In member function 'int MyFrame::Initialization()':
C:\TestApp\testapp.cpp:102:6: error: '((MyFrame*)this)->MyFrame::conn' does not have class type
  if (conn.connect("xxxxxxxxxxx", "localhost", "xxxx", "xxxxxxxx", xxxx))
      ^
C:\TestApp\testapp.cpp:104:26: error: '((MyFrame*)this)->MyFrame::conn' does not have class type
   mysqlpp::Query query = conn.query("SELECT xxxxxxxxxxxxxx FROM xxxxxxxxxxx");
                          ^
C:\TestApp\testapp.cpp: In member function 'void MyFrame::OnClose(wxCloseEvent&)':
C:\TestApp\testapp.cpp:136:2: error: '((MyFrame*)this)->MyFrame::conn' does not have class type
  conn.disconnect();
  ^
C:\TestApp\testapp.cpp: In member function 'void MyFrame::OnExit(wxCommandEvent&)':
C:\TestApp\testapp.cpp:143:2: error: '((MyFrame*)this)->MyFrame::conn' does not have class type
  conn.disconnect();
  ^

下面还有其他代码试图调用对象的 connect()disconnect() 方法,但如错误所示,无法识别。

即使我使用以下...

mysqlpp::Connection conn();

...允许构造函数使用默认初始化,编译器仍然会抛出除第 31 行之外的所有错误。

有什么想法吗?

这个字段声明看起来很奇怪。

mysqlpp::Connection conn(false);

尝试 mysqlpp::Connection conn; 并在构造函数的初始化列表中初始化它。