|
发表于 2005-10-8 20:08:36
|
显示全部楼层
可以编译通过,没有错误!
[code:1]
#include <iostream>
template <class Type, int size>
Type min(const Type (&r_array)[size])
{
Type min_val = r_array[0];
for( int i = 1; i < size; ++i)
if (r_array[i] < min_val)
min_val = r_array[i];
return min_val;
}
int main()
{
int array[5] = {5,4,3,2,1};
std::cout << min<int, 5>(array) << std::endl;
}
[/code:1]
C:\WINDOWS\system32\cmd.exe /c g++ -v
Reading specs from D:/App/MinGW/bin/../lib/gcc-lib/mingw32/3.2.3/specs
Configured with: ../gcc/configure --with-gcc --with-gnu-ld --with-gnu-as --host=
mingw32 --target=mingw32 --prefix=/mingw --enable-threads --disable-nls --enable
-languages=c++,f77,objc --disable-win32-registry --disable-shared --enable-sjlj-
exceptions
Thread model: win32
gcc version 3.2.3 (mingw special 20030504-1) |
|