0

I have a couple C++ programming questions and I would appreciate some help.

I am deriving a class “SpecialRFPulses” from another class “sRF_PULSE_ARB” and I would like to write a wrapper function “prep_DK( ----)” around the inherited member function “prepArbitrary(---)”. I have no idea how to do it.

This is what I am trying (obviously call of prepArbitrary is wrong):

extern MrProtocolData::MrProtData* pOrigProt;
extern MrProtocolData::SeqExpo &rSeqExpo;

class SpecialRFPulses: public sRF_PULSE_ARB
{
    public:
        SpecialRFPulses(long lDuration_In)
        {
            lDuration       = lDuration_In;  //in us

        }

        ~SpecialRFPulses(){
        }


        bool prep_DK (MrProtocolData::MrProtData &, MrProtocolData::SeqExpo &);
    protected:

    private:
        long lDuration; // in us
        long lStartTime_in_us; // in us
};

bool SpecialRFPulses::prep_DK (MrProtocolData::MrProtData &rMrProt, MrProtocolData::SeqExpo &rSeqExpo)
{
    NLS_STATUS    lStatus;


    // create myRFPulseArray and calculate dEffectiveAmplIntegral



    // HERE I WOULD HAVE LIKED TO USE prepArbitrary 
    //  Of course, this current syntax is WRONG.
    if (!myRFPulse.prepArbitrary(pOrigProt, &rSeqExpo, myRFPulseArray, dEffectiveAmplIntegral))
    {
        std::cout << "ERROR: "<<myRFPulse.getNLSStatus()<<std::endl;
        return (false);
    };

    return true;
}

Also, unlike other functions which usually takes reference to class MrProtData and SeqExpo, prepArbitrary defined in third party library takes pointer.

My questions are:

1) How to write a wrapper function around inherited function: prepArbitrary?

2) Rather than defining "pOrigProt" and "rSeqExpo" as extern, can I pass it as an argument to constructor of the derived class and then use this in wrapper function"prepDK(---)?

Any help would be very appreciated.

Regards, Dushyant

Garima Singh
  • 1,410
  • 5
  • 22
  • 46
  • 1
    What exactly is the problem? Your `prep_DK` would act like a wrapper as long as you call it rather than `prepArbitrary` to do stuff. And the only obviously wrong thing about the `prepArbitrary` call is that you can just call an inherited function; it's implicitly called on `this`: `if (!prepArbitrary...`. – molbdnilo Aug 08 '14 at 10:18
  • @molbdnilo . It worked. Since my knowledge in CPP is very limited, I did not know that I can call member function like you suggested. – Garima Singh Aug 08 '14 at 10:22
  • Have a look at [this list](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list) and focus on the "Beginner" section. – molbdnilo Aug 08 '14 at 10:28

0 Answers0