Hello
I am new to template programming, so i tried the 'example' from
http://www.sgi.com/tech/stl/functors.html.
I can compile the code but when i want to run the program
I get a segmentation fault when the part of std::sort(...) is
reached, but I don't understand why.
------------ Code start ---------------------
#include <iostream>
#include <vector>
struct less : public std::binary_function<double, double, bool> {
bool operator()(double x, double y) { return x < y; }
};
int main(){
std::vector<double> V(50);
std::generate(V.begin(), V.end(), rand);
std::sort(V.begin(), V.end(), less());
}
--------------- Code end -----------------------
thanks in advance
Manfred
PS: I am using linux and gcc 3.4.4 but this shouldn't be the problem
afaik