I recently encountered the definition of static class in C++ while going through the source code of ns2 simulator:
static class TCPHeaderClass : public PacketHeaderClass {
public:
TCPHeaderClass() : PacketHeaderClass("PacketHeader/TCP",
sizeof(hdr_tcp)) {
bind_offset(&hdr_tcp::offset_);
}
} class_tcphdr;
I have never encountered a static class in C++ before. What are the properties and uses of the same?
That is an unusual syntax to declare a static instance of TCPHeaderClass
called class_tcphdr
, equivalent to
class TCPHeaderClass : public PacketHeaderClass {
public:
TCPHeaderClass() : PacketHeaderClass("PacketHeader/TCP",
sizeof(hdr_tcp)) {
bind_offset(&hdr_tcp::offset_);
}
};
static TCPHeaderClass class_tcphdr;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With