我得到 錯誤C2027:使用未定義的類型「橋」錯誤C2027和錯誤C2227
和
錯誤C2227的:左邊的「 - >收到」必須指向類/結構/聯合/通用
在線* connection1-> receive(newMessage,2);
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#define MAXHOST 10
#define MAXPORT 5
#define MAXLAN 8
#define MAXBRIDGE 5
#define MAXLANBRIDGECON 2
using namespace std;
class Bridge;
class Host;
class Message;
class Simulation;
class Lan;
class Message{
//////////////
};
class Host{
Lan * lan1;
int id;
int nextMessageTime;
public:
/////////
};
class Lan{
Bridge *connection1, *connection2;
int bridgeConnection;
Host hostList[MAXHOST];
int id;
int hostCount;
public:
void connect(Bridge * const newBridge)
{
if(bridgeConnection==0)
{
connection1 = newBridge;
}
if(bridgeConnection==1)
{
connection2 = newBridge;
}
bridgeConnection++;
}
void receive(Message newMessage){
*connection1->receive(newMessage,2);
}
};
class Bridge{
/////////////////////
};
void main(){
Simulation newSim;
newSim.create();
return;
}
* connection1-> receive(newMessage,2); 我知道這條線是不正確的。我想我在嘗試「一切」之前,我發佈的代碼 – melih 2009-12-01 16:29:06