CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Apr 2002
    Posts
    65

    Stl collection set, how to use find

    I need to learn how to use the find method to search for a value in a set. But specifically,..... I need to search for an object that has a member variable with a particular value. For example I have
    a sample set below. I am inserting name, social security number and other information. I need to search for an object in the set that has a particular social security number. How do I do this?



    typedef std::set< MGenPName, std::less< MGenPName> > MGenPNameSet;
    typedef std::set< MGenPName, std::less< MGenPName> >::iterator MGenPNameSetIter;




    class MGenPName : private Terms // Class name
    {
    public: //ctor - dtor
    MGenPName(){;} ;

    // Accessor
    const CString& DName();
    const CString& DSynID();
    const int iSSNumber();
    void SetiSSNumber(int);
    .
    .
    }

    //

    void main(void)
    {

    MGenPName FirstOject;
    FirstObject.SetiSSNumber(3446668889);

    MGenPNameSet m_GpnTpnSet; // Collection

    // The set is loaded with MGenPname objects
    .
    .
    .
    // Now I want to search through the set: m_GpnTpnSet for the matching
    // Social security number. How do I do this ???
    //
    MGenPNameSetIter mIter = m_GpnTpnSet.begin();


    mIter.find( ???????); // I want to iterate through the
    // 3446668889 list until I find the
    //social security number



    }

  2. #2
    Join Date
    Apr 2002
    Posts
    65

    Disregard--> I figured it out

    Please disreagard my STL question

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