1

I'm new in programming and I'm practicing to use STL(Standard template library) against simple arrays

here I have simple codes which I wrote with simple loops and condition commands I want to convert it to STL but unfortunately, I do now which container should I use ? and how to write it. I think map container is good because it has key and value

here it is the first code :

CPOI temp(type, name,latitude, longitude,description);
    if (m_noPoi<10)
    {
        m_POI[m_noPoi]=temp;
        m_noPoi++;
    }

I have a class which names CPOI and I have a condition which use arrays apart from that I want to use STL against arrays.

and here is another code :

 CPOI* temp;
        for (int i=0;i<m_noPoi;i++)
        {
            if(name==m_POI[i].getName())
            {
                temp=&m_POI[i];
            }

        }

    return temp;
    }

here also the story is the same I tried to use the iterator and defined 10 items like this and I think I need a for loop which iterator check it but I do not know how to implement it my idea :

 vector<int> vec;
               for(int m_noPoi = 0; m_noPoi < 10; m_noPoi++){
                  vec.push_back(m_noPoi);
               }

I'll appreciate if somebody help me to develop this idea or guide me. Thanking in advance for your cooperation.

Beh
  • 21
  • 1
  • 5
    Please try to create a [Minimal, **Complete**, and Verifiable Example](http://stackoverflow.com/help/mcve) and show us. – Some programmer dude Nov 29 '16 at 07:20
  • 1
    You might also want to read e.g. [What's the difference between “STL” and “C++ Standard Library”?](http://stackoverflow.com/questions/5205491/whats-the-difference-between-stl-and-c-standard-library). – Some programmer dude Nov 29 '16 at 07:22
  • I want to create a condition like "if and a for loop" with STL and I used vector but I do not know how to implement it I have an idea to use iterator but I'm not familiar with the command and I get an error. if somebody help me how to implement "if and for loop" via iterator or give me an example I can get the idea and do it on my own. – Beh Nov 29 '16 at 17:42

0 Answers0