Thank you a lot.
There is only only on another question.
Assuming to have an filled array of integer, how can I convert it into a vector in line 9.
Regards.
I compiled it in C++2012 and have the following error.
1>------ Build started: Project: 3, Configuration: Debug Win32 ------
1> Source4.cpp
1>c:\users\art\documents\visual studio 2012\projects\3\3\source4.cpp(10): error C2552: 'my_array' : non-aggregates cannot be initialized with initializer list
1> 'std::vector<_Ty>' : Types with a base are not aggregate
1> with
1> [
1> _Ty=std::vector<int>
1> ]
1>c:\users\art\documents\visual studio 2012\projects\3\3\source4.cpp(10): error C2078: too many initializers
1>c:\users\art\documents\visual studio 2012\projects\3\3\source4.cpp(10): fatal error C1903: unable to recover from previous error(s); stopping compilation
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Excellent respond. Thank you a lot. You did a great job for me.
Just some other questions.
1- if I want to copy the sorted data of my_vector into my_array again in the end of program (line 21) what should I do?
2- why the size of my_vector is equal to size of my_array but the capacity of my_vector is more than its size.
3-the lines 11 and 12 in your last response is for transferring my_array[3][4] into my_vector[3][4]?
4- what is best: a-work with vectors in all of my program and forget the arrays or b- using the arrays and transfer it into vector and return it back when need
Regards.
what is best: a-work with vectors in all of my program and forget the arrays or b- using the arrays and transfer it into vector and return it back when need
Just work with vectors. They're almost always a better option than C-style arrays.
> 3-the lines 11 and 12 in your last response is for transferring my_array[3][4] into my_vector[3][4]?
Yes.
> 4- what is best: a-work with vectors in all of my program and forget the arrays
Yes. Even if the size of the array is a constant known at compile time, the simple value semantics of std::vector<> make the code for sorting (moving rows around) much more natural.