Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.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++ ASSERT-C+;的编译器错误+; #包括“stdafx.h” #包括 #包括 使用名称空间std; 甲级 { 公众: int IsLocked(); }; int A::IsLocked() { 返回false; } int main() { A a1; 断言(a1.IsLocked()); 返回0; }_C++_Compiler Errors - Fatal编程技术网

C++ ASSERT-C+;的编译器错误+; #包括“stdafx.h” #包括 #包括 使用名称空间std; 甲级 { 公众: int IsLocked(); }; int A::IsLocked() { 返回false; } int main() { A a1; 断言(a1.IsLocked()); 返回0; }

C++ ASSERT-C+;的编译器错误+; #包括“stdafx.h” #包括 #包括 使用名称空间std; 甲级 { 公众: int IsLocked(); }; int A::IsLocked() { 返回false; } int main() { A a1; 断言(a1.IsLocked()); 返回0; },c++,compiler-errors,C++,Compiler Errors,找不到将错误获取为断言标识符。。。。我也试过包括..应该是: #include "stdafx.h" #include <iostream> #include <assert.h> using namespace std; class A { public: int IsLocked(); }; int A::IsLocked() { return false; } int main() { A a1; ASSERT(a1.IsLoc

找不到将错误获取为断言标识符。。。。我也试过包括..

应该是:

#include "stdafx.h"
#include <iostream>
#include <assert.h>

using namespace std;

class A
{
public:
    int IsLocked();
};
int A::IsLocked()
{
    return false;
}

int main()
{
    A a1;
    ASSERT(a1.IsLocked());
    return 0;
}
注意小写。

应为:

#include "stdafx.h"
#include <iostream>
#include <assert.h>

using namespace std;

class A
{
public:
    int IsLocked();
};
int A::IsLocked()
{
    return false;
}

int main()
{
    A a1;
    ASSERT(a1.IsLocked());
    return 0;
}

注意小写。

此外,由于a1.IsLocked()将返回false,因此评估将失败。这可能是故意的,但我想我应该提到它。此外,由于a1.IsLocked()将返回false,因此断言将失败。这可能是故意的,但我想我应该提一下。