Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

How to call the API in C++

Shulou Source: shulou.com Published: 2022-06-01 19:48:34 09月27日 Update

This article mainly explains "how to call the interface in C++". The content in the article is simple and clear, and it is easy to learn and understand. Now please follow the editor's train of thought slowly and deeply. Let's study and learn how to call the interface in C++.

F.44 returns T & when you don't want a copy and you don't need a null return value.

Translator's note: the meaning of unwanted to copy is just to invoke the interface.

Reason (reason)

The language guarantees that a T & refers to an object, so that testing for nullptr isn't necessary.

The language guarantees that T & will definitely reference an object, so there is no need for nullptr checking.

Example (sample)

Class Car {array w; / /... public: wheel& get_wheel (int I) {Expects (I < w.size ()); return w [I];} / /.}

Void use () {Car c; wheel& w0 = c.get_wheel (0); / / w0 has the same lifetime as c}

Enforcement (implementation recommendations)

Flag functions where no return expression could yield nullptr .

Indicates a function that does not return an expression to generate nullptr.

Translator's note: this suggestion should be limited to functions that return a pointer type.

Thank you for your reading. the above is the content of "how to call the interface in C++". After the study of this article, I believe you have a deeper understanding of how to call the interface in C++. The specific use situation still needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Tags: Interface caching learning content function suggestion copy translator reason just meaning object that is ideas situations pointers articles more knowledge knowledge points Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Microsoft Docker Shulou Information macOS OPPO Reno