c++ - C++构建错误: class does not name a type

我重新排列了一些代码,现在出现以下错误:

g++ main.cpp myframe.cpp `wx-config --cxxflags --libs std` -o main
myframe.cpp:5:1: error: ‘Myframe’ does not name a type

我很确定该错误与内含物有关,而不与错误代码有关

这是源文件(仅相关部分):

main.cpp:
#include "main.h"
#include "myframe.h"

IMPLEMENT_APP(MyApp)

bool MyApp::OnInit(){  
    Myframe *menu = new Myframe(wxT("Application"));
    menu->Show(true);
    return true;
};

main.h:
#include <wx/wx.h>

class MyApp : public wxApp
{
  public:
    virtual bool OnInit();
};

myframe.cpp:
#include "main.h"

Myframe::Myframe(const wxString& title) 
/// ^ ERROR
       : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(300, 300))
{
  ...
}

myframe.h:
#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/

相关文章:

c++ - 我的编译方式错误吗?

c++ - 编译错误 “String does not name a type”

c++ - 编译简单的openCV项目

c# - 编译错误-您是否缺少using指令或程序集引用?

java - Java Swing GUI错误

c++ - 无法为参数错误将字符串转换为 'char*'?

c++ - 使用 "Length"的头文件的 For 循环中出现错误 C867

java - 实际参数和形式参数列表的长度不同(但两个长度均为2?)

java - 二进制运算符的错误操作数类型

java - 我正在做一个独特的值(value)java程序。我尝试错误