This is my header:
#ifndef TIMING_H
#define TIMING_H
#define MAX_MESSAGES 1000
typedef Message* MessageP; //inside the class?
class Timing {
public:
Timing();
private:
struct Message {
Agent *_agent;
double _val;
};
MessageP* _msgArr;
int _waitingMsgs;
};
My question is: do I have to place the typedef inside the class block right above MessageP* _msgArr or is it OK to place it near all the #define?
It doesn't output compilation errors so I'm not sure about it.
Outside of the class, that type must be referred as Timing::Message
, so
typedef Timing::Message* MessageP;
But this is possible only after the declaration of Timing::Message
, yet MessageP
is used before the declaration of Timing
is complete, so it's not possible.
Moreover, the struct is a private:
member, so you can't define this outside anyway. The typedef
must be done inside the Timing
class.
class Timing {
public:
Timing();
private:
struct Message {
Agent *_agent;
double _val;
};
typedef Message* MessageP; // <--
MessageP* _msgArr;
int _waitingMsgs;
};
You did not get compilation error probably because another Message
type in global scope already exists.
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