本文介绍了这个函数声明在c ++中是什么意思的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! c> const 表示此函数(它是一个成员函数)它被调用的对象的可观察状态。编译器通过不允许你从这个方法调用非 const 方法,并且不允许你修改成员的值来强制这样做。 throw()意味着你向编译器保证这个函数永远不会允许发出异常。这称为例外规范,而且(长故事短)是无用的,可能会误导。 virtual const char* what() const throw(){}AFAIK it's a function that will return a constant pointer to a mutable char. The rest I am not sure. Could anybody help? 解决方案 Regarding the const throw() part:const means that this function (which is a member function) will not change the observable state of the object it is called on. The compiler enforces this by not allowing you to call non-const methods from this one, and by not allowing you to modify the values of members.throw() means that you promise to the compiler that this function will never allow an exception to be emitted. This is called an exception specification, and (long story short) is useless and possibly misleading. 这篇关于这个函数声明在c ++中是什么意思的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-19 14:20