Is it possible to access private members of a class?

前端 未结 4 1269
既然无缘
既然无缘 2020-12-06 21:14

Is it possible to access private members of a class in c++.

provided you don\'t have a friend function and You don\'t have access to the class def

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-06 21:37

    I think there was some old school trick like this:

    #define private public
    #include "header.h"
    #define private private
    

    But you are strongly discouraged to do this (I've read quickly that the said something about this in the C++ standard) - if you want to read more about this google for "#define private public"

提交回复
热议问题