从另一个类内部调用C ++类

时间:2015-11-08 20:30:28

标签: c++

我有一个问题,我真的希望有人可以帮助我,或指出我正确的方向。基本上我有以下C ++代码:

void ComparePackets::run_timer(Timer *)
{
    Packet *p = input(1).pull();
    if (p)
        p->kill();
    _timer.reschedule_after(_interval);
}

我需要从以下代码块中调用/运行此代码:

void ComparePackets::check(Packet *p, Packet *p)
{
    bool different = false;
    if (p->length() != q->length())
    different = true;
    do
    {
        ////Insert code to call ComparePackets::run_timer(Timer *) code here///
    }
    while (p->length() == 106);
}

我已经尝试过我所知道的一切,(当然不多),但是在编译所有代码时只是不断收到错误信息。这段代码背后的想法是当长度为106字节的数据包出现在另一个接口上时,以预设的时间间隔从一个接口丢弃数据包。 任何帮助非常感谢!

ComparePackets类是:

class ComparePackets : public Element { public:

ComparePackets() CLICK_COLD;
//TimedSink() CLICK_COLD;

const char *class_name() const        { return "ComparePackets"; }
const char *port_count() const        { return "2/2"; }
const char *processing() const        { return PULL; }
//int configure(Vector<String> &, ErrorHandler *) CLICK_COLD;
int initialize(ErrorHandler *) CLICK_COLD;
void cleanup(CleanupStage) CLICK_COLD;
//void add_handlers() CLICK_COLD;

Packet *pull(int);
void run_timer(Timer *);///////////

私人:

Packet *_p[2];
bool _available[2];
NotifierSignal _signal[2];

bool _timestamp : 1;
Timer _timer;///////////////////
Timestamp _interval;////////////////

//uint32_t _ndiff;
//enum { D_LEN, D_DATA, D_TIMESTAMP, D_NETOFF, D_NETLEN, D_NETHDR,
  // D_MORE_PACKETS_0, D_MORE_PACKETS_1, D_LAST };
//uint32_t _diff_details[D_LAST];

void check(Packet *, Packet *);
//static String read_handler(Element *, void *) CLICK_COLD;
//static int write_handler(const String &, Element *, void *, ErrorHandler *) CLICK_COLD;

};

1 个答案:

答案 0 :(得分:0)

你有p !!的双重定义。

void ComparePackets::check(Packet *p, Packet *p)

修正:

void ComparePackets::check(Packet *p, Packet *q)
相关问题