84669 person learning
152542 person learning
20005 person learning
5487 person learning
7821 person learning
359900 person learning
3350 person learning
180660 person learning
48569 person learning
18603 person learning
40936 person learning
1549 person learning
1183 person learning
32909 person learning
请问各位有没有什么办法禁止实例化的对象调用类内的某个方法呢
拥有18年软件开发和IT教学经验。曾任多家上市公司技术总监、架构师、项目经理、高级软件工程师等职务。 网络人气名人讲师,...
If you want to prohibit access to a class method, put this method in private and protected
class Test { public: void func1(); private: void func2(); }
Here func1 can be called from the object, func2 can only be called inside the class.
I don’t understand...private methods cannot be called outside the class.
Yes, write the method (function) to private: After the following, this method is a private method and can only be called in methods of this class. However, objects instantiated by this class cannot call this method. .
If you want to prohibit access to a class method, put this method in private and protected
Here func1 can be called from the object, func2 can only be called inside the class.
I don’t understand...private methods cannot be called outside the class.
Yes, write the method (function) to private: After the following, this method is a private method and can only be called in methods of this class. However, objects instantiated by this class cannot call this method. .