CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    May 1999
    Posts
    28

    Serializing an Array

    Trying to serialize a CPoint array of points for a drawing program so that drawing is saved when the file is saved, but not having too much success.

    Would appreciate assistance in examining the following code to see what I am doing wrong.

    Thanks in advance for your help.

    void CSimpleAppView::Serialize(CArchive& ar)
    {
    Serialize(ar);
    if (ar.IsStoring())
    { // storing code
    ar << m_Color; //Store the pen color
    ar << m_ptCount; //Store the drawing
    for (int i = 0; i < m_ptCount; i++) //to be retrieved
    {
    ar << PointArray[i].x;
    ar << PointArray[i].y;
    }
    }
    else
    { // loading code
    ar >> m_Color; //Retrieve the pen color
    ar >> m_ptCount; //Retrieve the previous
    for (int i = 0; i < m_ptCount; i++) //drawing
    {
    ar >> PointArray[i].x;
    ar >> PointArray[i].y;
    }
    }
    }



  2. #2
    Guest

    Re: Serializing an Array

    You have not indexed your array!


  3. #3
    Join Date
    May 1999
    Posts
    28

    Re: Serializing an Array

    I have; it just doesn't show up when posted here.(must have something to do with the square brackets)


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured