How do I use arrays in C++?

Answer

Arrays on the type level

An array type is denoted as T[n] where T is the element type and n is a positive size, the number of elements in the array. The array type is a product type of the element type and the size. If one or both of those ingredients differ, you get a distinct type:

#include<type_traits>static_assert(!std::is_same<int[8],float[8]>::value,"distinct element type");static_assert(!std::is_same<int[8],int[9]>::value,"distinct size");

Note that the size is part of the type, that is, array types of different size are incompatible types that have absolutely nothing to do with each other. sizeof(T[n]) is equivalent to n * sizeof(T).

All c++ Questions

Ask your interview questions on c

Write Your comment or Questions if you want the answers on c from c Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---