gpt4 book ai didi

c++ - 错误 C4430 : missing type specifier/error C2143: syntax error : missing ';' before '*'

转载 作者:太空宇宙 更新时间:2023-11-03 10:21:57 30 4
gpt4 key购买 nike

我在同一行收到两个错误。 Bridge *在 Lan 类中排名第一。我错过了什么?

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;


class Lan{
Bridge *first;
Bridge *second;
Host hostList[10];
int id;
};

class Bridge{
Lan lanList[5];
};




class Host{
Lan * lan;
int id;
public:
Host(int newId)
{
id=newId;
}
};



void main(){

return;
}

最佳答案

Lan之前声明Bridge

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

class Bridge;

class Lan{
Bridge *first;
Bridge *second;
Host hostList[10];
int id;
};

class Bridge{
Lan lanList[5];
};

关于c++ - 错误 C4430 : missing type specifier/error C2143: syntax error : missing ';' before '*' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1815431/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com