A Complete Guide to Programming in C++ part 6

A Complete Guide to Programming in C++ part 6. This book provides both novice and experienced programmers with a comprehensive resource manual for the C++ programming language. Readers gain experience in all aspects of programming, from elementary language concepts to professional software development, with in depth coverage of all the language elements en route. These elements are carefully ordered to help the reader create useful programs every step of the way. | NAMES 29 Valid Names Within a program names are used to designate variables and functions. The following rules apply when creating names which are also known as identifiers a name contains a series of letters numbers or underscore characters _ . German umlauts and accented letters are invalid. C is case sensitive that is upper- and lowercase letters are different. the first character must be a letter or underscore there are no restrictions on the length of a name and all the characters in the name are significant C keywords are reserved and cannot be used as names. The opposite page shows C keywords and some examples of valid and invalid names. The C compiler uses internal names that begin with one or two underscores followed by a capital letter. To avoid confusion with these names avoid use of the underscore at the beginning of a name. Under normal circumstances the linker only evaluates a set number of characters for example the first 8 characters of a name. For this reason names of global objects such as functions should be chosen so that the first eight characters are significant. Conventions In C it is standard practice to use small letters for the names of variables and functions. The names of some variables tend to be associated with a specific use. EXAMPLES c ch for characters i j k l m n for integers in particular indices x y z for floating-point numbers To improve the readability of your programs you should choose longer and more self-explanatory names such as start_index or startindex for the first index in a range of index values. In the case of software projects naming conventions will normally apply. For example prefixes that indicate the type of the variable may be assigned when naming variables. 30 CHAPTER 2 FUNDAMENTAL TYPES CONSTANTS AND VARIABLES VARIABLES Sample program Definition and use of variables include iostream using namespace std int gVarl Global variables int gVar2 2 explicit initialization int main char ch A Local variable being .

Không thể tạo bản xem trước, hãy bấm tải xuống
TÀI LIỆU MỚI ĐĂNG
8    63    2    16-05-2024
34    413    6    16-05-2024
14    69    1    16-05-2024
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.