c++ - 如何在自己的类中使用 wxWidgets 类型?

标签 c++ wxwidgets

我正在编写一个基于 wxWidgets 库的应用程序。我有一些支持应用程序数据的类。它们使用类型作为 std::string,不应在使用 wxWidgets lib 编写的应用程序中使用。 例如

class SomeClass
{
    private:
      char name[80];
      (.....)
    public:
      (.....)
};

现在我有类似的东西:

class SomeClass
{
    private:
      wxString name;
      (.....)
    public:
      (.....)
};

(是的,我知道 char 不是字符串 - 我决定将 char 更改为字符串)。 编译器抛出错误: 'wxString' 没有命名类型 我尝试在很多地方包含带有类的文件,但结果总是一样。

最佳答案

如果编译器说 wxString 没有声明那么你必须包含正确的头文件。

声明这一行,确保它不在 #ifndef WX_PRECOMP 中。

#include <wx/string.h>

关于c++ - 如何在自己的类中使用 wxWidgets 类型?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9071562/

相关文章:

c++ - g++ 抛出 Skeleton wxwidget 项目 "undefined reference to main"错误

python - 在点获取对象? wxpython

c++ - 主对话框关闭后关闭对话框

c++ - 三角形问题

c++ - 在 wxPanel 上绘画或添加许多 wxControls?

python - mysqldb更新报错typeerror 'str' object is not callable

c++ - wxWidgets 有某种垃圾收集器吗?

c++ - 在析构函数中清除 vector 可以吗

安卓NDK : Static library used is different than precompiled library specified

c++ - 我们还需要 "placement new"和 "operator new"吗?