一种访问类中数据成员的新方法  

A Novel Approach to Accessing the Data-members of a Class

在线阅读下载全文

作  者:王秋梅[1] 

机构地区:[1]洛阳工业高等专科学校自动化系,河南洛阳471003

出  处:《洛阳工业高等专科学校学报》2004年第3期38-40,共3页Journal of Luoyang Technology College

摘  要:介绍C++中,不通过类的接口而对其数据成员进行访问的新方法。该方法根据C++对象模型的特点,通过一个指向待访问的数据成员的指针和一个指向全局(或静态)变量的指针,分别获得待访问的auto类型数据成员指针和静态数据成员指针,从而实现了对类的数据成员的访问。该方法同时说明了类提供的保护和封装对数据成员的安全是不可靠的。In the paper, a novel approach to access the data-members of a class in C++ is introduced. According to the C++ object model, an auto type data-member pointer and a static type data-member pointer are respectively acquired by using one pointer which points to the accessed data-members and another pointer which points to the accessed static variability. And these two acquired pointers achieve the purpose of accessing the data-members. The approach also shows that data-member securities offered by class protection and encapsulation are usually undependable.

关 键 词: 数据成员 对象 访问控制 指针 强制转换 

分 类 号:TP311.12[自动化与计算机技术—计算机软件与理论]

 

参考文献:

正在载入数据...

 

二级参考文献:

正在载入数据...

 

耦合文献:

正在载入数据...

 

引证文献:

正在载入数据...

 

二级引证文献:

正在载入数据...

 

同被引文献:

正在载入数据...

 

相关期刊文献:

正在载入数据...

相关的主题
相关的作者对象
相关的机构对象