0

私はこの構造を持っています:

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{};
};

クラスのメンバー変数です。

BETHEL_SPEAKER_SERVICE_TALK_INFO_S GetBethelServiceTalkInfo() const { return m_BSSTI; }

この構造を自分のCArchive. 現時点では、私は保管のために持っています:

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);

読み方も似ています:

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);

<<構造自体にand>>演算子を追加することは可能ですか?


operator<<リンクされた回答で言及されているものを試すのは初めてですが、問題が発生しています。たとえば、私は試しました:

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);

そして、私のコードの他の部分では:

ar << m_BSSTI;

しかし、コンパイルすると:

7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(44,49): error C2061: syntax error:

識別子 'BETHEL_SPEAKER_SERVICE_TALK_INFO_S' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(45,2): エラー C2805: バイナリ 'operator <<' のパラメーターが少なすぎます 7>D:\My Programs\ 2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(46,3): エラー C2059: 構文エラー: 'return' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(53,48) : エラー C2238: ';' の前に予期しないトークンがあります 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(55,1): エラー C2143: 構文エラー: ';' がありません 前 '}' 7>D:\My Programs\2022\MeetSchedAssist\Meeting Schedule Assistant\SpecialEventManager.h(55,1): エラー C2059: 構文エラー: '}' 7>AssignSelectedColumnDlg.cpp


これまでのところ完全なものは次のとおりです。

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);
    }
};

上記の場合、最初のエラーは行番号 44 にあります。これは次のとおりです。

friend CArchive& operator<<(CArchive& rArchive, BETHEL_SPEAKER_SERVICE_TALK_INFO_S const& rsBSSTI)
4

0 に答える 0