how to initialize static character string in a class?

I have a class which is actually a group of functions

class{
static char errbuf[PCAP_ERRBUF_SIZE];
public:

static func1();
static func2();
....
}

since I only want to use these function, I don't need to instantiate the class. so all the members are static.

some of these functions need to use a character string errbuf to print error info. so there is a static member errbuf.

but a static member variable should be initialized before it is used in functions.
so how to initialize the errbuf?

besides, is the OOP in this design is a bit odd? if so, how to do the OOP design for such a scenario?


BTW: what is wrong with cplusplus forum? I can't use the Format

Last edited on
your_header_file.hpp:
1
2
3
4
5
6
7
8
class A{
static char errbuf[PCAP_ERRBUF_SIZE];
public:

static func1();
static func2();
....
}

your_implementation_file.cpp:
char A::errbuf[PCAP_ERRBUF_SIZE] = {};


besides, is the OOP in this design is a bit odd? if so, how to do the OOP design for such a scenario?
It depends on what you are trying to accomplish.
besides,
1
2
besides, is the OOP in this design is a bit odd? if so, how to do the OOP design for such a scenario?
It depends on what you are trying to accomplish.


this class is only a group of functions
isn't the target and background clear?
thanks
Last edited on
Topic archived. No new replies allowed.