我重新排列了一些代码,现在出现以下错误:
g++ main.cpp myframe.cpp `wx-config --cxxflags --libs std` -o main
myframe.cpp:5:1: error: ‘Myframe’ does not name a type
#include "main.h"
#include "myframe.h"
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit(){
Myframe *menu = new Myframe(wxT("Application"));
menu->Show(true);
return true;
};
#include <wx/wx.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
#include "main.h"
Myframe::Myframe(const wxString& title)
/// ^ ERROR
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(300, 300))
{
...
}
#include <wx/wx.h>
#include <wx/menu.h>
class Myframe : public wxFrame
{
public:
Myframe(const wxString& title);
...
};
...(function definitions,event table and enums)
最佳答案
您可以将#include <myframe.h>
添加到“myframe.cpp”文件中。
因为在“myframe.cpp”文件中没有Myframe的定义。
https://stackoverflow.com/questions/40816781/