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 use the this pointer of a class in C++

2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

Most people do not understand the knowledge points of this article "how to use the this pointer of classes in C++", so the editor summarizes the following contents, detailed contents, clear steps, and has a certain reference value. I hope you can get something after reading this article. Let's take a look at this "how to use this pointers of classes in C++" article.

In C++ 's class, non-static member functions have a hidden this pointer, and all member variables in the function body are accessed through the this pointer. But the this pointer is transparent to the user, the user does not need to display to pass parameters to the this pointer, the compile time will automatically receive parameters.

First, the attention points of the this pointer

When calling a member function, you cannot pass parameters to the this pointer.

Declaration this pointers that cannot be displayed when defining member functions

Inside member functions, you can display using this pointers

Use a date class to describe the attention points of the this pointer:

Class Date {public: void Print () {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