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 master the pointer basis of C++

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article introduces you how to master C++ pointer basis, the content is very detailed, interested friends can use for reference, I hope it can be helpful to you.

C++ pointers are just like other variables, except that general variables contain actual real data, while the pointer is an indicator. These are some basic problems of C++ pointers. It is also a very important concept in C++ pointers.

It tells the program in which area of memory the data can be found. This is a very important concept, there are many programs and algorithms are designed around pointers, such as linked lists. How do you define a pointer? Just like you define another variable, except that you precede the pointer name with an asterisk.

Let's look at an example: the following program defines two pointers, both of which point to integer data. Have you noticed the "p" prefix in front of the two variable names? This is a habit that programmers usually use when defining the C++ pointer base to improve the readability of the poop, indicating that it is a pointer. Now let's initialize these two pointers:

# include void main () {/ / declare variables: int nNumber; int * pPointer; / / now assign them values: nNumber = 15; pPointer = & nNumber; / / print out the value of the variable nNumber: 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

Development

Wechat

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

12
Report