#ifndef COMMUNICATIONNETWORK_H
#define COMMUNICATIONNETWORK_H
#include <iostream>
struct City{
std::string cityName;
std::string message;
City *next;
City(){}; // default constructor
City(std::string initName, City *initNext, std::string initMessage)
{
cityName = initName;
next = initNext;
message = initMessage;
}
};
class CommunicationNetwork
{
public:
CommunicationNetwork();
~CommunicationNetwork();
void addCity(std::string, std::string);
void buildNetwork();
void transmitMsg(char *); //this is like a string
void printNetwork();
protected:
private:
City *head;
City *tail;
};
#endif // COMMUNICATIONNETWORK_H
我只是想知道創建城市的鏈表究竟該.H並/套了,我怎麼會在我CommunicationsNetwork.cpp進行以及我的main.cpp構建給定城市的列表。使用結構類給出.h文件中C++
注意:此代碼最終應該能夠將城市添加到列表中,打印鏈表中的城市並傳輸消息,但我目前只是試圖創建鏈接列表。
我想你應該實現'CommunicationNetwork'中聲明的函數。 –
你在早先的作業中做了些什麼? – Beta
如果你給了這些,你應該也已經被描述了什麼是一切以及他們應該做什麼。對於局外人來說,這是不可能猜到的。 – molbdnilo