![]() |
Create a function that prints multidimensional array size by dimensions i.e.: Input : int a[2][3][4]; printDimensions(a); Output : 2x3x4 Input : int b[5][6]; printDimensions(a); Output : 5x6
To solve this problem we should use template function to figure out the size of current array. Then we call this function recursively till the last dimension. For last dimension the boundary overridden template function should be used. The implementation of the idea: CPP
Output:
2x3x4
Pay attention the order of two template functions. It won’t compile if you switch them. CPP
Output:
2x3x4
If you think that template names are too long to print you are not alone. There are short aliases in C++17: |
Reffered: https://www.geeksforgeeks.org
C++ |
Related |
---|
![]() |
![]() |
![]() |
![]() |
![]() |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 10 |