Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/145.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ QT创建者,返回(C+;+;)_C++_Qt_Return_Qt Creator - Fatal编程技术网

C++ QT创建者,返回(C+;+;)

C++ QT创建者,返回(C+;+;),c++,qt,return,qt-creator,C++,Qt,Return,Qt Creator,有人能解释一下为什么使用这两种类型的退货吗 int parse(QTextStream& out, const QString fileName) { QDomDocument doc; QFile file(fileName); if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) { out<<"Datei "<<fileName<<" nicht lesb

有人能解释一下为什么使用这两种类型的退货吗

int parse(QTextStream& out, const QString fileName) {
    QDomDocument doc;
    QFile file(fileName);
    if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
        out<<"Datei "<<fileName<<" nicht lesbar"<<endl;


>   return 1;

    }
    QString errorStr;
    int errorLine;
    if (!doc.setContent(&file, false, &errorStr, &errorLine)) {
        out<<"Fehler in Zeile "<<errorLine<<": "<<errorStr<<endl;


>  return 2;

    }
    ...
}
int解析(QTextStream&out,常量QString文件名){
QDOM文件文档;
QFile文件(文件名);
如果(!file.open(QIODevice::ReadOnly | QIODevice::Text)){

out在第一个示例中,函数提前返回以指示错误。无法打开文件,因此函数将向该函数的调用者返回值。无法设置内容,函数将向调用者返回不同的值

if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
    out<<"Datei "<<fileName<<" nicht lesbar"<<endl;

    return 1; // return value to caller
}

在函数
main()的末尾
返回0;
表示程序成功运行。

在第一个示例中,函数提前返回以指示错误。无法打开文件,因此函数将向该函数的调用方返回值。无法设置内容,函数将向调用方返回其他值

if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
    out<<"Datei "<<fileName<<" nicht lesbar"<<endl;

    return 1; // return value to caller
}

在函数
main()的末尾
返回0;
表示程序成功运行。

在第一个示例中,函数提前返回以指示错误。无法打开文件,因此函数将向该函数的调用方返回值。无法设置内容,函数将向调用方返回其他值

if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
    out<<"Datei "<<fileName<<" nicht lesbar"<<endl;

    return 1; // return value to caller
}

在函数
main()的末尾
返回0;
表示程序成功运行。

在第一个示例中,函数提前返回以指示错误。无法打开文件,因此函数将向该函数的调用方返回值。无法设置内容,函数将向调用方返回其他值

if (!file.open(QIODevice::ReadOnly|QIODevice::Text)) {
    out<<"Datei "<<fileName<<" nicht lesbar"<<endl;

    return 1; // return value to caller
}
在函数
main()
的末尾,
返回0;
表示程序成功运行。

没有不同的“类型”属于
return
。您需要
return;
其中
是您想要的函数返回值。在您的代码中,函数可能返回不同的值以表示请求操作的不同结果。没有不同的“类型”属于
return
。您需要
return;
其中
是您想要的函数返回值。在您的代码中,函数可能返回不同的值以表示请求操作的不同结果。没有不同的“类型”属于
return
。您需要
return;
其中
是您想要的函数返回值。在您的代码中,函数可能返回不同的值以表示请求操作的不同结果。没有不同的“类型”您可以执行
return;
其中
是您想要的函数返回值。在您的代码中,函数可能返回不同的值以表示请求操作的不同结果。