I have this structure:
using BETHEL_SPEAKER_SERVICE_TALK_INFO_S = struct tagBethelSpeakerServiceTalkInfo
{
    CString strHost;
    CString strCohost;
    CString strChairman;
    CString strOpenPrayer;
    CString strSpeaker;
    CString strTheme;
    int iSongOpen{};
    int iSongClose{};
};
It is a member variable in a class:
BETHEL_SPEAKER_SERVICE_TALK_INFO_S GetBethelServiceTalkInfo() const { return m_BSSTI; }
I want to serialize this structure to my CArchive. At the moment I have for storing:
ar << m_bSpecialEventBethelServiceTalk;
ar << m_BSSTI.strHost;
ar << m_BSSTI.strCohost;
ar << m_BSSTI.strChairman;
ar << m_BSSTI.strOpenPrayer;
ar << m_BSSTI.strSpeaker;
ar << m_BSSTI.strTheme;
ar << gsl::narrow<WORD>(m_BSSTI.iSongOpen);
ar << gsl::narrow<WORD>(m_BSSTI.iSongClose);
Similar for reading:
ar >> m_bSpecialEventBethelServiceTalk;
ar >> m_BSSTI.strHost;
ar >> m_BSSTI.strCohost;
ar >> m_BSSTI.strChairman;
ar >> m_BSSTI.strOpenPrayer;
ar >> m_BSSTI.strSpeaker;
ar >> m_BSSTI.strTheme;
m_BSSTI.iSongOpen = readAndCast<int, WORD>(ar);
m_BSSTI.iSongClose = readAndCast<int, WORD>(ar);
Is it possible to add << and >> operators to the structure itself?
I am new to trying out the operator<< referred to in the linked answer but I am having issues. For example, I tried:
friend CArchive operator<<(CArchive& rArchive, BETHEL_SPEAKER_SERVICE_TALK_INFO_S const& rsBSSTI)
{
    return  rArchive << rsBSSTI.strHost
                     << rsBSSTI.strCohost
                     << rsBSSTI.strChairman
                     << rsBSSTI.strOpenPrayer
                     << rsBSSTI.strSpeaker
                     << rsBSSTI.strTheme
                     << gsl::narrow<WORD>(rsBSSTI.iSongOpen)
                     << gsl::narrow<WORD>(rsBSSTI.iSongClose);
And in the other part of my code:
ar << m_BSSTI;
But when I compile:
7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(44,49): error C2061: syntax error:identifier 'BETHEL_SPEAKER_SERVICE_TALK_INFO_S' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(45,2): error C2805: binary 'operator <<' has too few parameters 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(46,3): error C2059: syntax error: 'return' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(53,48): error C2238: unexpected token(s) preceding ';' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(55,1): error C2143: syntax error: missing ';' before '}' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(55,1): error C2059: syntax error: '}' 7>AssignSelectedColumnDlg.cpp
Here is the full thing so far:
using BETHEL_SPEAKER_SERVICE_TALK_INFO_S = struct tagBethelSpeakerServiceTalkInfo
{
    CString strHost;
    CString strCohost;
    CString strChairman;
    CString strOpenPrayer;
    CString strSpeaker;
    CString strTheme;
    int iSongOpen{};
    int iSongClose{};
    friend CArchive& operator<<(CArchive& rArchive, BETHEL_SPEAKER_SERVICE_TALK_INFO_S const& rsBSSTI)
    {
        return  rArchive << rsBSSTI.strHost << rsBSSTI.strCohost
                         << rsBSSTI.strChairman
                         << rsBSSTI.strOpenPrayer
                         << rsBSSTI.strSpeaker
                         << rsBSSTI.strTheme
                         << gsl::narrow<WORD>(rsBSSTI.iSongOpen)
                         << gsl::narrow<WORD>(rsBSSTI.iSongClose);
    }
};
With the above the first error is on line #44 which is:
friend CArchive& operator<<(CArchive& rArchive, BETHEL_SPEAKER_SERVICE_TALK_INFO_S const& rsBSSTI)
