小编Hul*_*gan的帖子

访问具有相同名称的外部结构

看看我的示例代码

struct A
{
   int member;
};

int main()
{
   int A; //Line 1
   A b;   //Line 2 
   b.member = int(); //Line 3
}
Run Code Online (Sandbox Code Playgroud)

错误是

prog.cpp: In function ‘int main()’:
prog.cpp:9: error: expected `;' before ‘b’
prog.cpp:9: warning: statement has no effect
prog.cpp:10: error: ‘b’ was not declared in this scope
Run Code Online (Sandbox Code Playgroud)

如何在第二行访问结构A?为什么我还是得到错误?

c++ compiler-errors

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

标签 统计

c++ ×1

compiler-errors ×1