当前位置:网站首页>Accessing private members using templates
Accessing private members using templates
2022-04-23 18:52:00 【Brick Porter】
#include <iostream>
class B {
int aa = 0,bb=3;
int a=10;
public:
void print()
{
std::cout << "a=" << a << std::endl;
}
};
typedef int B::* stolen_mem_ptr;
template<stolen_mem_ptr MemPtr>
class Robber {
friend stolen_mem_ptr steal() {
return MemPtr;
}
};
template class Robber<&B::a>;
stolen_mem_ptr steal();
int main()
{
B b;
b.print();
auto accessor = steal();
b.*accessor = 100;
b.print();
std::cout << "Hello World!\n";
}
版权声明
本文为[Brick Porter]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210603257607.html
边栏推荐
- The type initializer for ‘Gdip‘ threw an exception
- : app: transformclasseswithrobustfordevrease meituan hot repair compilation error record
- Eight bit binary multiplier VHDL
- Fundamentals of machine learning theory -- some terms about machine learning
- 中金财富怎么样?在上边开户安全吗
- Simple use of navigation in jetpack
- ctfshow-web361(SSTI)
- Use of content provider
- ESP32 LVGL8. 1 - msgbox message box (msgbox 28)
- Use Chenxi bookkeeping book to analyze the balance of revenue and expenditure of each account in a certain period of time
猜你喜欢
Introduction to ROS learning notes (I)
七、DOM(下) - 章节课后练习题及答案
Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.
Machine learning theory (7): kernel function kernels -- a way to help SVM realize nonlinear decision boundary
Halo open source project learning (VII): caching mechanism
MySQL学习第五弹——事务及其操作特性详解
Practice of Druid SQL and security in meituan review
PyGame tank battle
How to virtualize the video frame and background is realized in a few simple steps
Summary of actual business optimization scheme - main directory - continuous update
随机推荐
Get a list of recent apps
ctfshow-web362(SSTI)
Esp32 (UART event) - serial port event learning (1)
One of the reasons why the WebView web page cannot be opened (and some WebView problem records encountered by myself)
Solutions such as unknown or garbled code or certificate problem prompt in Charles's mobile phone packet capture, actual measurement.
Druid SQL和Security在美团点评的实践
机器学习理论基础篇--关于机器学习的一些术语
ctfshow-web361(SSTI)
教你用简单几个步骤快速重命名文件夹名
电路在线模拟
Simple use of navigation in jetpack
C language simulates entering and leaving the stack, first in first out, first in first out, shared memory
Advanced transfer learning
After CANopen starts PDO timing transmission, the heartbeat frame time is wrong, PDO is delayed, and CANopen time axis is disordered
中金财富怎么样?在上边开户安全吗
机器学习实战 -朴素贝叶斯
[popular science] CRC verification (I) what is CRC verification?
Use Chenxi bookkeeping book to analyze the balance of revenue and expenditure of each account in a certain period of time
Esp32 (UART ecoh) - serial port echo worm learning (2)
SQL中函数 decode()与 replace()的用法