A bit of __c++ for C + +

Source: Internet
Author: User

Have to say that C + + is really anti-human ah.

The same function, which needs to be declared in the header file, is implemented in the source file.

Specific to QT implementation, for a small function, need to register a slot in the header file, register a signal, declare a function to send signal, and then write the slot in the source file, and then in the initialization of signal and slot link together, Finally, we should implement function emit Signal.

When the Ros is realized, it is necessary to declare the topic name, Subscriber, subscription function in the source file, and then bind the Subscriber and subscription function together, and then write out the implementation of the subscription function.

In other words, even if you do a very simple thing, you need to change the program 6 places, and these 6 places are unrelated, distribution is very scattered. Without very good clear habits and good code style will soon be not maintainable.

In addition, if it involves pointers, but also to worry about when the pointer release, how to write can improve efficiency, how to ensure that the pointer is thread-safe ...

In addition, write any variables, functions, classes should be repeatedly considered this writing is efficient, naming there is no problem, should not add a namespace, a place did not write well waiting for someone else's spit.

Even if there is no problem written above, the final program will be written cmakelists or makefile to manage, there are a lot of learning. And the Chinese information is very few, need to consult a large number of English manuals in order to have a preliminary understanding to understand the makefile or CMake documents written by others (once will write CMake once let me have a sense of superiority, until these days to see some open Source Library CMake completely do not understand to find themselves really drawings. This will cause any further changes in the project and you will need to come back and modify these two files. Ros also added a package.xml also need to manually modify, otherwise compile an error. I've always wanted to spit. Since you can check if CMake and package are consistent, then why not make these two into one or use CMake to automatically generate Package.xml.

Therefore, in scientific research, unless the idea has been very clear, otherwise do not directly on C + +, it is best to have a mature python or matlab to achieve a step-by-step rewrite into C + +. If you think about it, you'll get out of the way.

Cherish life, away from C + +.

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.