What is the correct syntax of declaring array of pointers of integers of size 10 in C++?

Đức Linh

New member
What is the correct syntax of declaring array of pointers of integers of size 10 in C++?
A. int arr = new int[10];
B. int **arr = new int*[10];
C. int *arr = new int[10];
D. int *arr = new int*[10];
 
Answer: b
Explanation: As we have to declare an array of pointers of integers therefore we need double pointer array in which each element is collection pointers to integers. Therefore the correct syntax is int **arr = new int*[10];
 

Tìm kiếm

Back
Top