error C4430: missing type specifier / error C2143: syntax error : missing ';' before '*'
I am getting both errors on the same line. Bridge *first in the开发者_运维问答 Lan class. What am i missing?
#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;
}
Declare Bridge before Lan
#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];
};
You are missing the forward declaration for Bridge. Otherwise when compiling Lan class compiler doesn't know what Bridge* is. You should tell the compiler that Bridge is a class which you are going to define later. Forward declare it as class Bridge; before class Lan
Just put a class Bridge; before the declaration of the Lan class.
Bridge is not defined at the moment it is used.
you need a forward declaration so that the compiler knows that Bridge is a valid class name. before the Lan class, write:
class Bridge;
Bridge doesn't exist until after the Lan declaration. you should forward-declare Bridge. besides that, Lan won't compile because Host is not known either, and forward declaration won't help, because the compiler needs to know Host's size.
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论