Java programmers Look at C + + code

Source: Internet
Author: User

Engaged in a few years of Android application development, which has been developed in Java for several years, this year to find an OEM company, plainly speaking is the Android system source customization, in this company learning Python, C + +. Because the exposure to JNI will be a little bit more, so I would like to talk to you about some of the C + + code understanding.

I'm mainly looking at the code and maintaining the code from the point of view, not involving a deeper technical aspect. We also welcome you to discuss your own understanding.

First I personally like the header file of C + + very much. C + + header file is similar to Java1.8 interface, you can define all the interface method/virtual function Here, I think the good header file should be the DataSet + Behavior specification collection, as well as the need to override the quilt class default implementation of the function, Java1.8 has already discussed why interface methods for interface classes need to give the default implementation. This is involved in a lot of things, I would like to tidy up next time for everyone to send out.

In my superficial understanding, the header file accommodates the many benefits of Java interfaces and abstract classes, perfectly separating the definition from implementation, and the implementation of the CPP is almost completely ignored when developing the code. The maintenance of the code is very convenient. But from the point of view of the code, C + + has a Java-like static import function,

Like what

public class A {public         static final int status_start = 0;     public static final int status_stop = 1;}

  

Static Import A.status_start; Static Import A.status_stop;  Public class B {}

With static import, when Class B is used with Status_start and status_stop, it is completely hidden from their source when used in code. I personally look at the code habits, sometimes very awkward. The advantage is that there is a seamless combination of code that can be completely. But the downside is that maintenance people spend more time looking at the initial definition of the reference. C + + is so hard to find citations everywhere.

Finally, the first time to write a blog, write bad place, also please friends forgive me.

Java programmers Look at C + + code

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.