Let's say I have the following code:
void func(const char *arr[])
{
std::cout << sizeof(arr) << ", " << sizeof(char*) << std::endl;
}
int main()
{
const char *arr[] = { "aaa","bbb","ccc" };
std::cout << sizeof(arr) << ", " << sizeof(char*) << std::endl;
func(arr);
return 0;
}
The output is:
24, 8
8, 8
Ok, I understand that char *[]
will be implicitly converted into char **
. But I think that in case of implicit conversion should be a way of explicit avoiding such a situation.
Otherwise I see 2 idempotent (or looks like idempotent) expressions that are completely different in fact.
How to definitely avoid this conversion? I expect to get the same 24, 8 in the function.
P.S. A know about vector etc. I'm just interested in the meaning of having such ambiguity.