I have a structure called PDU in llcp.h, also in here is a class called LLCP, inside which I'm creating a static instance of the PDU structure, however, when I attempt to define this static member variable in my cpp file, I receive the message: "error: 'PDU' has not been declared", here's the code:
This doesn't make sense. First you already declared LLCP::pdu to be of type PDU, so no need to do it again in the .cpp file. Then you cannot set a structure to value 0. What would you expect that to do? Fill the structure with zeros?
pylon:
This doesn't make sense. First you already declared LLCP::pdu to be of type PDU, so no need to do it again in the .cpp file. Then you cannot set a structure to value 0. What would you expect that to do? Fill the structure with zeros?
It does, I've declared pdu in the header but not defined it, which in C/C++ because it's static needs doing in the namespace in the C++ source file. I don't need the = 0, but the problem still occurs even if I omit this.
Your syntax is slightly off. There are a couple of ways to initialise struct members to default values. The old way is { 0 } the new way is PDU(). I flipped a coin and will show the old way. The following compiles: