Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to understand the post-setting of the return type of Category 11

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces "how to understand the return type post of Cnotify 11". In the daily operation, I believe that many people have doubts about how to understand the return type post of Cnotify 11. The editor has consulted all kinds of data and sorted out simple and easy-to-use operation methods. I hope it will be helpful for you to answer the questions of "how to understand the return type post of Cnotify 11". Next, please follow the editor to study!

Return type post

In addition to constructors and destructors, function declarations need to specify the return type of the function. In traditional C or C++, the function declaration looks something like this:

Int getSum (int a, int b)

The first int is the return type of the function, which indicates that the return type of the function is an integer. After the new Category 11, we can also declare that:

Auto getSum (int a, int b)-> int

Write auto where you originally put the return value type, followed by a'- > 'after the end of the function declaration, followed by the return value type of the write function. The effect of the two methods is the same.

Returns an array pointer

In general, when a function returns multiple data, it chooses to encapsulate the data in a class (or structure) or directly return a pointer.

These two ways are either troublesome or there is no way to get the amount of data. In fact, our real requirement is to return an array pointer (which can calculate dimensions). This method exists:

Int (* getResultArray (int mode)) [10]

In the form above, a pointer that returns an array of 10 integers is declared. For such a pointer, we can use it like an array:

Auto arr = getResultArray (1)

Cout

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report