You are taking quiz cppquiz.org/q/htr7f. After 0 of 10 questions, you have 0.00 points.
Question #140 Difficulty:
According to the C++23 standard, what is the output of this program?
#include <iostream>
size_t get_size_1(int* arr)
{
return sizeof arr;
}
size_t get_size_2(int arr[])
{
return sizeof arr;
}
size_t get_size_3(int (&arr)[10])
{
return sizeof arr;
}
int main()
{
int array[10];
// Assume sizeof(int*) != sizeof(int[10])
std::cout << (sizeof(array) == get_size_1(array));
std::cout << (sizeof(array) == get_size_2(array));
std::cout << (sizeof(array) == get_size_3(array));
}
Hint:
§[dcl.fct]¶5 in the standard:
any parameter of type “array of
T
” (...) is adjusted to be “pointer toT
”".
Mode : Quiz
If you want to quit the current quiz and go back to training mode, click here.