Array and pointer of C ++

Source: Internet
Author: User
Tags array definition

Array Definition

The dimension of the array must be defined by a constant expression greater than or equal to 1. This constant expression can only contain an integer nominal value constant, an enumeration constant, or an integer const object initialized using a constant expression.

Non-const variables and the const variables whose values are not known at the runtime cannot be used to define the dimension of the array.

Const   Int Size = Get_size ();
Int A_size =   26 ;
Int Table [size]; // Error
Int Array [a_size]; // Error

//Although the size is a const int constant, the value cannot be obtained in the compilation phase. A_size is an integer variable, and its value may be changed during runtime. Therefore, the size of the array must be determined at runtime, so it is invalid.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.