In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
Editor to share with you what C++ security issues are, I believe most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!
Access the subclass's own virtual function through the pointer of the parent type
We know that it is pointless for a subclass not to overload the virtual function of the parent class. Because polymorphism is also based on function overloading. Although we can see the virtual function of Derive in the virtual table of Base1 in the above figure, it is impossible for us to use the following statement to call the own virtual function of the subclass:
Any attempt to use a parent pointer to call a member function in a subclass that does not override the parent class will be considered illegal by the compiler, so such a program cannot be compiled at all. But at run time, we can access the virtual function table by pointer to violate the security of C++. (I'm sure you can do this by reading the code in the appendix below.)
In addition, if the virtual functions of the parent class are private or protected, but these non-public virtual functions will also exist in the virtual function table, so we can also access these non-public virtual functions by accessing the virtual function table, which is easy to do.
Class Base {private: virtual void f () {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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.