what does this function declaration mean in c++

前端 未结 11 1904
-上瘾入骨i
-上瘾入骨i 2020-12-24 13:12
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.

11条回答
  •  孤独总比滥情好
    2020-12-24 13:43

    From left to right:

    • virtual - this function may be overridden in derived classes
    • const char* - this function returns a modifiable pointer to a constant (array of) char
    • what() - this function takes no parameters
    • const - this function does not modify the (non-mutable) members of the object on which it is called, and hence can be called on const instances of its class
    • throw() - this function is not expected to throw any exceptions. If it does, unexpected will be called.

提交回复
热议问题