小编Neo*_*nix的帖子

C++ struct初始化断言失败

#include <cassert>
#include <string>
struct AStruct 
{ 
    int x; 
    char* y; 
    int z; 
};
int main()
{ 
    AStruct structu = {4, "Hello World"};
    assert(structu.z == ???);
}
Run Code Online (Sandbox Code Playgroud)

我应该写什么来取代???成功的断言?
我用过assert(structu.z == 0);但很遗憾得到了错误
int main(): Assertion 'structu.z == 0 failed.Aborted'

c++ struct assert

3
推荐指数
1
解决办法
766
查看次数

标签 统计

assert ×1

c++ ×1

struct ×1