In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/02 Report--
C++ how to use auto to express multi-dimensional array pointers, many novices are not very clear, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can get something.
Pointer to a multidimensional array
A multidimensional array is a common data structure, which is actually an array of arrays. Although this meaning is easy to understand, it is a bit troublesome to define pointers to manipulate array data. Suppose you have the following two-dimensional array.
Int matrix [10] [10]
Which of the following is true when defining a pointer to one of the rows?
Int * row [10]
Int (* row) [10]
The answer is the second. Memorizing is one way, of course, but you can also look at the code in a different way:
Int* row [10]
Int (* row) [10]
The first case is an array of pointers, and the rest are pointers to the array.
How to deal with Clipper 11
After clocking 11, with the auto descriptor and the begin/end function, it is easier to define multi-dimensional array pointers. For example, you can write code like this:
Int matrix [10] [10]
Int number = 1
For (auto row = begin (matrix); row! = end (matrix); + + row)
{
For (auto data = begin (* row); data! = end (* row); + + data) {
* data = number++
}
}
Because row is an array pointer, while begin and end require reference types, the argument used when calling the begin and end functions to get the data pointer is * row, not row.
Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.