错误:C4430:缺少类型说明符-假定为int.注意:C++不支持default-int

error: C4430: missing type specifier - int assumed. Note: C++ does not support default-int

本文关键字:int 注意 不支持 default-int C++ C4430 类型 错误 说明符      更新时间:2023-10-16

我在寡妇7中使用Qt创建者5.10。

我写了一个tcp套接字程序。

#include <QTcpSocket>
QTcpSocket *tcpClient;
tcpClient = new QTcpSocket(this);

错误:

1   missing type specifier - int assumed. Note: C++ does not support default-int
2   'tcpClient' : 'int' differs in levels of indirection from 'QTcpSocket *'
3    'this' : can only be referenced inside non-static member functions

如果tcpClient是全局变量,正如这段代码所建议的那样,您不能在全局范围内的单独语句中初始化它。只有变量声明、命名空间声明和函数可以在全局范围内。

此外,this只能在非静态类方法的实现体内部使用。

相关文章: