本文主要是介绍c++ error: redefinition of ‘struct ac::bd’ struct ac::bd:fg,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
#include <iostream>
#include <stdio.h>
class ac
{
public:
class bd;
};
class ac::bd
{
public:
struct fg;
};
struct ac::bd:fg
{
int a = 1;
};
int main()
{
return 0;
}
编译时报错:
g++ -c -o class-struct.o class-struct.cpp
class-struct.cpp:16:12: error: redefinition of ‘struct ac::bd’
16 | struct ac::bd:fg
| ^~
class-struct.cpp:10:11: note: previous definition of ‘struct ac::bd’
10 | class ac::bd
| ^~
问题:
struct ac::bd:fg 这里少了一个':'号。
修改:
struct ac::bd::fg
这篇关于c++ error: redefinition of ‘struct ac::bd’ struct ac::bd:fg的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!