我有一段時間沒有碰過C++,希望有人能指出問題出在我的類定義中。我不斷收到一個錯誤,說「錯誤:'IPsource'沒有命名一個類型」。C++類初始化語法和錯誤「不命名類型」
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++;
}
};
然後裏面主要我有...
AddressPacketList IPsource();
IPsource.add("Hello");
您包含哪些文件? – RonaldBarzell
這是[最煩人的解析](http://en.wikipedia.org/wiki/Most_vexing_parse)。 –