错误:“xxx”没有命名类型
error: ‘xxx’ does not name a type
我有一个奇怪的问题,我不明白。我正在将一些C代码复制到c++类中,无法通过此错误"未命名类型"…我希望我复制了足够多的代码来让它有意义,原始程序是~1000行
错误是…错误:' HTTPContext '没有指定类型
错误行是"HTTPContext MainWindow::*find_rtp_session_with_url(const char *url, const char *session_id)"
className.h:
class MainWindow : public QMainWindow
{
Q_OBJECT
public:
typedef struct HTTPContext{
int fd;
}HTTPContext;
HTTPContext *find_rtp_session_with_url(const char *url,
const char *session_id);
};
className.cpp
#include "className.h"
HTTPContext MainWindow::*find_rtp_session_with_url(const char *url,
const char *session_id)
{
HTTPContext *rtp_c;
}
HTTPContext
是在类作用域中声明的,因此要在全局作用域中的函数定义中使用,您需要显式指定它:
MainWindow::HTTPContext *MainWindow::find_rtp_session_with_url...
你需要说
MainWindow::HTTPContext* MainWindow::find_rtp_session_with_url( ...
,因为它是内部类。你也不必在这里使用typedef
:
struct HTTPContext {
int fd;
};
足以在c++中命名一个类型
相关文章:
- ArduinoJson 6.15.2:JsonObject没有命名类型
- 防止主数据类型C++的隐式转换
- 大量序列中核苷酸类型的快速计数
- 如何从C++中的依赖类型中获得它所依赖的类型
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 是否可以初始化不可复制类型的成员变量(或基类)
- 如何获取std::result_of函数的返回类型
- 从父命名空间重载类型
- 如果C++类在类方法中具有动态分配,但没有构造函数/析构函数或任何非静态成员,那么它仍然是POD类型吗
- 我想将一个对T类型的非常量左值引用绑定到一个T类型的临时值
- Openssl 1.1.1d无效使用不完整的类型"struct dsa_st"
- 访问者访问变体并返回不同类型时出错
- 在VS2010-VS2015下编译时,如何使用decltype作为较大类型表达式的LHS
- Eclipse/CDT_C++给出"语义错误_"类型XXX无法解决"。项目运行
- YYY 中的错误 XXX 未命名类型
- 错误:xxx 不命名类型
- 错误:“xxx”没有命名类型
- C/C++代码中的奇怪之处(ISO C++禁止声明没有类型的"xxx")
- XXX 中发生了类型 'System.ExecutionEngineException' 的未处理异常.exe
- 错误:'xxx'不是类型