You are taking quiz cppquiz.org/q/nb5gc. After 0 of 10 questions, you have 0.00 points.
Question #140 Difficulty:
According to the C++17 standard, what is the output of this program?
#include <iostream>
using namespace std;
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])
cout << (sizeof(array) == get_size_1(array));
cout << (sizeof(array) == get_size_2(array));
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 to T”".
Mode : Quiz
If you want to quit the current quiz and go back to training mode, click here.