C ++ Data Types

Source: Internet
Author: User

Before giving you a detailed introduction to the C ++ data type, let's first understand the C ++ data type, and then introduce the C ++ data type comprehensively, and the length of the C ++ data type. I 'd like to share it with you here, hoping it will be useful to you...

The integer types in C language include char, short, int, long, etc. The following section describes the C language's requirements on the length of each data type:
(A). The short and long types have different lengths.
(B) The int type is usually the same as the physical character length of a specific machine.
(C ). short is usually 16 bits, and int Is usually 16 bits or 32bits. Each compiler can be determined based on different hardware, but short and int must be at least 16 bits, the long type must be at least 32 bits, and the short type must be shorter than the int and long types.

The sizeof () operator returns the number of bytes contained in a data type (bytes). AnsiC requires that sizeof (char) must return 1. When sizeof acts on an array, returns the number of bytes occupied by all the members in the array (note that it is not the number of members in the array). When sizeof () Acts on the struct and the public body, the returned value is not only the total number of bytes of data members, but also the bytes that the compiler fills in to implement the bytes.

C ++ data type length problem:
1. bytes and length
Bytes. Eight bits are a fixed concept. Word Length refers to the length of binary data that can be processed by a computer at a time. It is a non-fixed concept. For example, the length of an 8-bit computer is 8, that is, one byte. The length of a 32-bit computer is 32, that is, four bytes. Similarly, the length of a 64-bit computer is 64, 8 bytes.

II. C ++ Data Types in C ++
1. Character-type data char, which is always an 8-bit long byte.
2. Integer: int, short, and long. Generally, int Is a word length, short is half a word length, and long is one or two characters in 32-bit machines ).
3. float, double, and long double indicate Single-precision floating-point double and Extended Floating-point respectively. In typical cases, float is a word, double is two words, and long double is two or three or four words.

Obviously, if you cannot find the reason for requiring the C ++ data type, it is nonsense to talk about the "correct learning method. First, repeat Bjarne's statement: "Our system is already extremely complex. To avoid the complexity of C ++, we simply don't need the C ++ Linus approach ." In all areas where C and C ++ are available, C ++ is a better language than C.

When I say "better", I mean C ++ has a safer type check, better abstract mechanism, and better database than C. Of course, there are exceptions in everything. If project 1 you are working on is not large. 2) There is no abstraction mechanism in coding, or even ADT abstracts data types.

For example, std: complex, which does not contain polymorphism and inheritance) is not used, RAII is not used, and exceptions are not used. 3) You don't need to connect to the basic library, such as smart pointers and containers that simplify resource management. Maybe you can use C. If you do, you don't have to argue with me because I can't refute you. The fields we are talking about here are roughly the areas listed by Bjarne in the "C ++ Application List.

The bottom line is: Remove unnecessary complexity from C ++, leave essential and important language features, simplify the language model, and eliminate historical burdens. Even the opponents of C ++ may have difficulty finding a reason to say "I still don't need C ++ ". In my opinion, there is only one reason for rational opposition to C ++ in a practical sense: the confusions brought by the complexity of C ++ offset or even exceed the benefits of the abstract mechanism and library of C ++ in his specific project.

  • C ++ compilation mode description
  • Better Design of object-oriented C ++ Language
  • Describes the features of C ++ compiling language to the greatest extent.
  • Analysis of Native C ++ in Windows Embedded CE
  • Summary of C ++ features introduced by famous Microsoft experts

It is worth noting that a trap should be avoided here, that is, once people determine the C ++ data type, this reason will "grow their feet", that is, even if we get rid of the complexity of C ++, they may still insist on not using C ++ and find a bunch of reasons for it. I assume you are not such a person.

However, perhaps most likely, he would say, "The problem is that the C ++ we are using today is not so concise.) your assumptions are not true ." Yes, my assumptions are not true. However, although we cannot eliminate complexity, we can avoid complexity and short-term growth. This is also the main point of this article. I will discuss it later.

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.