Hi Kind-DaniWebbers,

How do you initialise a boost::archive:binary_oarchive in a different place to where you declare it?
So:

class CBase {
    std::ofstream m_ofs;
    boost::archive:binary_oarchive m_binOA(); // <== default constructor
    virtual void Open(std::string& s) = delete;
};

class CDerived : CBase {
    void Open(std::string& s) override
    {
        CBase::m_ofs("filename.bin", std::ios::binary);
        CBase::m_binOA(CBase::m_ofs, /*flags*/); // <== says error C2660: '...'::m_binOA' : 
                                                 // function does not take 2 arguments
    }
};

I am trying to create different interfaces for XML, TXT and BIN. So I just derive from the one I want. Is this the way to do it? I struggling to design this. Please can I have some help.

Thanks.

ok ok...
It was a silly question. That's why noone replied to me. You obviously use a pointer to the object. Heres an OTT version using smart pointers:

    boost::shared_ptr<boost::archive::binary_oarchive> m_spBinOA; // Bin Out
    boost::shared_ptr<boost::archive::binary_iarchive> m_spBinIA; // Bin In

Then in some implementation somwhere...

// Set flags for boost
ISerialization::m_iBoostFlags = boost::archive::no_header;

// Create boost binary output archive
ISerialization::m_spBinOA = 
    boost::make_shared<boost::archive::binary_oarchive>
        (m_ofs, m_iBoostFlags);

Tada: now I have just paid Daniweb to put my own post here since noone replied :P (hehe)
Comments welcome...

This article has been dead for over six months. Start a new discussion instead.