L
Lars Tetzlaff
Ioannis said:Lars said:Ioannis said:Second correction:
==> SomeClass::SomeClass(const SomeClass &):vec(VectorSize)
{
using namespace std;
for(TypeVector::size_type i= 0; i< vec.size(); ++i)
vec= rand();
sort(vec.begin(), vec.end());
}
You will never get a sorted vector. Every time you copy an element you
will change it's value!
I think during sort(), the default assignment operator is used, and not
the copy constructor.
You have to make a copy during the exchange of two elements:
SomeClass tmp = vec; // new value here
vec = vec[j];
vec[j] = tmp;
Lars