C + + Learning Note _02 The difference between a const in C + + and a final keyword in Java

Source: Internet
Author: User

(1) Final defines constants in Java that can be used for primitive types or class types, and if they are in a class type, such a type cannot be a parent

Class is inherited, that is, it cannot have subclasses under it, and such classes are called atomic classes.
Const-defined constants in C + +

(2) Final in Java if it is for the basic type, it is the same as the const of C + +
But if it's different for the object,

(3) final indicates that the handle is immutable
Final Object obj= (object) New String ("a");
Obj= (Object) New String ("Hello"); it's illegal.
However, you can still invoke the method of obj. such as ((String) obj). Length () is legal

C + + If an object is defined as const, you cannot invoke the object's methods. Unless this method is defined as const.

0012 represent performance, symbol, Representative, agent; play

0013 algorithm algorithm

Evaluation and evaluation of 0014 evaluate

0015 Prompt prompting

0016 specified designation details

Comparative comparison of 0017 contrast Compare

0018 Indentation Indent Indent

0019 remaining the remainder of the remaining

C + + Learning Note _02 The difference between a const in C + + and a final keyword in Java

Related Article

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.