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 std::addressof in Clipper 11

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

Share

Shulou(Shulou.com)05/31 Report--

In this article, the editor introduces in detail "how to use std::addressof in Category 11". The content is detailed, the steps are clear, and the details are handled properly. I hope this article "how to use std::addressof in Craft 11" can help you solve your doubts.

1. Source code preparation

This article is based on the analysis of the source code of gcc-4.9.0, std::addressof is added to the standard, so the lower version of gcc source code does not have this, it is recommended to choose 4.9.0 or newer version to learn, different versions of gcc source code should be different, but the principle and design ideas are the same.

2. Introduction to std::addressof

The purpose of std::addressof is to get the actual address of an object, even if the & operator of that object has been overloaded. It accepts a parameter that is a reference to the object to which the address is to be obtained. Let's take a look at how to use std::addressof through a very simple example

# include # include # include class Test {public: int* operator& () {return & b;} int* a_addr () {return & a;} int* b_addr () {return & b;} private: int a; int b;}; int main (int argc, char* argv []) {Test t; std::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