Home > Archive > VC Language > June 2005 > About the third parameter of std::sort in VC6.
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
About the third parameter of std::sort in VC6.
|
|
| 77123036@163.com 2005-06-08, 4:02 am |
| why this programme cannot be built in vc6(there are two link error),but
successful in gcc or vc7?
------------------
#include <iostream>
#include <algorithm>
template <class T>
inline bool less(T _a, T _b)
{
return _a < _b;
}
int main(void)
{
int a[10] = {65, 23, 654, 87, 12, 56, 231, 15, 58, 78};
std::sort(a, a + 10, ::less<int> );
return 0;
}
------------------
And this is successful in vc6 and vc7 and gcc:
------------------
#include <iostream>
#include <algorithm>
inline bool less(int _a, int _b)
{
return _a < _b;
}
int main(void)
{
int a[10] = {65, 23, 654, 87, 12, 56, 231, 15, 58, 78};
std::sort(a, a + 10, ::less);
return 0;
}
------------------
| |
| Carl Daniel [VC++ MVP] 2005-06-08, 4:02 am |
| 77123036@163.com wrote:
> why this programme cannot be built in vc6(there are two link
> error),but successful in gcc or vc7?
Becuase VC6 is 7 years old, nearly 3 versions out of date, and quite
dificient in it's handling of templates.
-cd
|
|
|
|
|