Arraylist in c++

hi,
I am looking equivalent of below in c++

ArrayList neww = new ArrayList();
neww.Add(2.02);
neww.Add(1.02);
neww.Add(3.03);
neww.Sort();

Thanks
Do you mean something like this?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <vector>
#include <algorithm>
#include <iostream>

int main() {
    std::vector<double> arr;
    arr.push_back(2.02);
    arr.push_back(1.02);
    arr.push_back(3.03);
    std::sort(arr.begin(), arr.end());

    for (auto x : arr) 
        std::cout << x << "\n";

    return 0;
}
1.02 
2.02
3.03
TwilightSpectre is right. std::vector is the C++ equivalent of Java's ArrayList.

http://www.cplusplus.com/reference/vector/vector/
Last edited on
Thanks to Everyone!
Last edited on
Topic archived. No new replies allowed.