mardi 31 mai 2016

Can I call a function from the base class which return bool from derived class

I have the following base class:

class node_layer_manager_t : public layer_manager_t
{
protected:
    //Devices
    trx_t        trx;
private:
    std::vector<string>               trx_dump_labels;

public:
    node_layer_manager_t( xml::node_t& params ); 
    ~node_layer_manager_t();

    virtual bool    set_profile(void) override;    
}

I created the following derived class:

class node_layer_manager_with_rad_t : public node_layer_manager_t
{
protected:
    //Devices
    radio_t radio;

public:
    node_layer_manager_with_rad_t(xml::node_t& params );
    ~node_layer_manager_with_rad_t();

    virtual bool    set_profile(void) override;

    virtual void radio_monitoring_job_function(void);

    intervalues_t<double>   radio_tmp;
    ushort          duration_seconds_for_radio_monitoring;
};

I want it so that the set profile will execute the set_profile of the base class and in addition some other action.

Can I just write it this way?

bool node_layer_manager_with_rad_t::set_profile(void)
{
    node_layer_manager_t::set_profile();
    try
    {
        string_t profile_tag = "logs/trx_dump/node:"+get_id();
        dev_tx = profile->get_decendant(profile_tag.c_str());
        cout<<"sarit id= "<< get_id()<<endl;
        success = true;
    }
    catch(...)
    {
        cout<<"sarit  profile error: "<<endl;
        success = false;
    }
    return success;  //**
}

**Or should I reurn the follwing:

return (success success&&node_layer_manager_t::set_profile()); 

Aucun commentaire:

Enregistrer un commentaire