Hi, all:
I have some question regarding to the example in ns-manual ch9.6(creating an new protocol) as follows:
class ECHO_Timer;
class ECHO_Agent : public Agent {
....
protected:
ECHO_Timer echo_timer_;
}
class ECHO_Timer : public TimerHandler {
public:
ECHO_Timer(ECHO_Agent *a) : TimerHandler() { a_ = a;}
protected:
virtual void expire(Event *e)
{
a_->timeout(0);
}
ECHO_Agent *a_
}
It gives me error:
echo_timer_ has incomplete type.
Two questions:
1. Can we circularly call each other in two classes. For example,
ECHO_Agent declare a ECHO_Timer in its class and ECHO_Timer has an instance
of ECHO_Agent.
2. since the only construtor of ECHO_Timer needs an ECHO_Agent pointer,I
change the declaration of echo_timer to:
ECHO_Timer echo_timer_(new ECHO_Agent);
It doen't work either.
How should I declare the echo_timer_?
Any help is appreciated!
minzhen
Minzhen Yang
2171 McLAUGHLIN AVE #3
SAN JOSE CA95122-3504
U.S.A.