我有一段时间没有接触 C++,希望有人能指出我的类定义中的问题所在。我不断收到一条错误消息,提示“错误:'IPsource' 没有命名类型”。
class AddressPacket {
std::string address;
int packets;
public:
void initialize(std::string add) {
address = add;
packets = 1;
}
std::string getAddress() {
return address;
}
int getPackets() {
return packets;
}
bool checkAddress(std::string add) {
return address == add;
}
void addPacket() {
packets++;
}
};
class AddressPacketList {
AddressPacket masterList[100];
int listCounter;
public:
AddressPacketList() { listCounter = 0; }
void add(std::string add) {
masterList[listCounter].initialize(add);
listCounter++;
}
};
然后在 main 我有...
AddressPacketList IPsource();
IPsource.add("Hello");