none
Replica for std::vector::iterator in MFC

    Question

  • Dear Techies,

    I just need the replica for " std::vector<MyClass*>::iterator it; "type.

    I made it as CArray<*MyClass*, MyClass> lMyClass;

    Please rectify me If I go incorrect, and I would appreciate if I could get the correct replica for" std::vector<MyClass*>::iterator it; "

    Thanks in advance.

    Regards,

    Aditzz

    Monday, April 09, 2012 3:38 PM

Answers

  • On 4/9/2012 11:38 AM, aditz wrote:

    I just need the replica for " std::vector<MyClass*>::iterator it; "type.

    I made it as CArray<*MyClass*, MyClass>  lMyClass;

    CArray doesn't provide anything like an iterator. Just use an index to access its elements.


    Igor Tandetnik

    • Proposed as answer by Helen Zhao Friday, April 13, 2012 4:38 AM
    • Marked as answer by Helen Zhao Monday, April 16, 2012 7:25 AM
    Monday, April 09, 2012 3:51 PM
  • Dear Techies,
     
    I just need the replica for " std::vector<MyClass*>::iterator it; "type.
    Why? Just use std::vector. So much better than CArray in every way.
     

    David Wilkinson | Visual C++ MVP
    • Proposed as answer by Helen Zhao Friday, April 13, 2012 4:38 AM
    • Marked as answer by Helen Zhao Monday, April 16, 2012 7:25 AM
    Tuesday, April 10, 2012 2:23 AM

All replies

  • On 4/9/2012 11:38 AM, aditz wrote:

    I just need the replica for " std::vector<MyClass*>::iterator it; "type.

    I made it as CArray<*MyClass*, MyClass>  lMyClass;

    CArray doesn't provide anything like an iterator. Just use an index to access its elements.


    Igor Tandetnik

    • Proposed as answer by Helen Zhao Friday, April 13, 2012 4:38 AM
    • Marked as answer by Helen Zhao Monday, April 16, 2012 7:25 AM
    Monday, April 09, 2012 3:51 PM
  • Dear Techies,
     
    I just need the replica for " std::vector<MyClass*>::iterator it; "type.
    Why? Just use std::vector. So much better than CArray in every way.
     

    David Wilkinson | Visual C++ MVP
    • Proposed as answer by Helen Zhao Friday, April 13, 2012 4:38 AM
    • Marked as answer by Helen Zhao Monday, April 16, 2012 7:25 AM
    Tuesday, April 10, 2012 2:23 AM
  • Actually what is your requirement and what  you want to do .Elaborate it little bit more so easy to answer that what u should do

    Thanks


    Rupesh Shukla

    Tuesday, April 10, 2012 3:30 AM
  • A simple pointer like ‘MyClass ** p = myArray.GetData()’ can be used to iterate between myArray.GetData() and  myArray.GetData() + myArray.GetSize().

    Tuesday, April 10, 2012 5:47 AM
  • aditz wrote:
    >
    >I just need the replica for " std::vector<MyClass*>::iterator it; "type.
    >
    >I made it as CArray<*MyClass*, MyClass> lMyClass;
    >
    >Please rectify me If I go incorrect, and I would appreciate if I could
    >get the correct replica for" std::vector<MyClass*>::iterator it; "
     
    Dave's reply is the correct one.  The MFC containers are not nearly as
    robust or performant as STL containers.  Use STL.
    --
    Tim Roberts, timr@probo.com
    Providenza & Boekelheide, Inc.
     

    Tim Roberts, VC++ MVP Providenza & Boekelheide, Inc.
    Thursday, April 12, 2012 5:42 AM