首页 | 本学科首页   官方微博 | 高级检索  
     

一种访问类中数据成员的新方法
引用本文:江姝妍.一种访问类中数据成员的新方法[J].重庆科技学院学报(自然科学版),2005,7(3):86-88,99.
作者姓名:江姝妍
作者单位:洛阳工业高等专科学校,洛阳471003
摘    要:介绍了在C 中不通过类的接口而对其数据成员进行访问的新方法.该方法根据C 对象模型的特点,通过一个指向待访问的数据成员的指针和一个指向全局(或静态)变量的指针,分别获得待访问的auto类型数据成员指针和静态数据成员指针,从而实现了对类的数据成员的访问.该方法同时表明了类提供的保护和封装对数据成员的安全是不可靠的.

关 键 词:  数据成员  对象  访问控制  指针  强制转换
文章编号:1673-1980(2005)03-0086-03
收稿时间:2005-05-09
修稿时间:2005-05-09

A New Approach to Accessing the Data-members of a Class
JIANG Shu-yan.A New Approach to Accessing the Data-members of a Class[J].Journal of Chongqing University of Science and Technology:Natural Science Edition,2005,7(3):86-88,99.
Authors:JIANG Shu-yan
Affiliation:Luoyang Technology College, Luoyang 471003
Abstract:In this paper,a new approach to accessing 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 variable.And through these two acquired pointers the data-members access is achieved.The new approach also shows that data-member protection offered by class and security from capsulation are usually unreliable.
Keywords:class  data-member  object  access control  pointer  compulsion conversion
本文献已被 CNKI 维普 万方数据 等数据库收录!
设为首页 | 免责声明 | 关于勤云 | 加入收藏

Copyright©北京勤云科技发展有限公司  京ICP备09084417号