#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