Hi,

I'm not an expert or anything, but I wish to add my opinion on it, which may 
somehow help.

In the first class structure you used, the error might be due to the handle 
function needing to be overridden in the myChannel class, but it's not.
In the second class structure, since you couldn't derive myChannel from 
TimerHandler class, you cannot refer to its resched method anymore or so it 
seems to me.
Hope this gives an idea at least and good luck with your work. 

 


________________________________
 From: Fazlullah Khan <fazlullah....@gmail.com>
To: ns-users <ns-users@ISI.EDU> 
Sent: Sunday, January 6, 2013 8:10 AM
Subject: [ns] Error in Code
 

Hey everybody!
I hope all fellows are fine. I am stuck in coding and get the
following errors. Pieces of cod and errors are below, any body can
help me in removing these errors.
Thank you all!    
//First Method    
/////////////////////////// myMac.h ///////////////////////////
    class myMacTimer : public Handler {
    virtual void handle(Event *e) = 0;    
    //stuff
    }
    
    class myMac : public Mac {
    friend class myChannel;
    public:
    myChannel chnl_;

    };

    class myChannel : public myMacTimer {
    public:
    myChannel(myMacTimer *a) : myMacTimer() { a_ = a;}
    void  expire(Event *e);

    protected:
      myMacTimer *a_;
    };
    
/////////////////////////// myMac.cc ///////////////////////////
    #include"myMac.h"
    void myChannel::expire(Event *)
    {
        if(true)
        {
        double x = Random::exponential(0.6);
        a_->chnl_.resched(x);
        }
    }

        error: cannot declare field ‘myMac::myChannel’ to be of abstract
type ‘myChannel’
        note:   because the following virtual functions are pure within 
‘myChannel’:
        note:     virtual void myMacTimer::handle(Event*)
        make: ***  Error 1
        
//Second Method
/////////////////////////// myMac.h ///////////////////////////
    class myMacTimer : public Handler {
    virtual void handle(Event *e) = 0;    
    //stuff
    }
    
    class myMac : public Mac {
    friend class myChannel;
    public:
    
    private:
    myChannel *chT;
    };
    
    class myChannel : public myMacTimer { //if I derive it from
TimerHandler then the error says ‘TimerHandler’ is not a direct base
of ‘Mac802_15_4’
    public:
    myChannel(myMacTimer *a) : myMacTimer() { a_ = a;}
    void  expire(Event *e);

    protected:
      myMacTimer *a_;
    };
    
///////////////////////    myMac.cc ///////////////////////////
    #include"myMac.h"
    void myChannel::expire(Event *)
    {
        if(true)
        {
        double x = Random::exponential(0.6);
        a_->chT.resched(x);
        }
    }
error: request for member ‘resched’ in
‘((myChannel*)this)->myChannel::a_->myMac::chT’, which is of non-class
type ‘myChannel*’

Anybody can suggest the solution.
Regards
Khan

Reply via email to