5

In the following member function declaration, I am unable to understand why there are two functions, what() and throw() in the same declaration? What does this mean? I am a beginner in c++ and I might not have studied this concept. Please help me out or point out the material which I must read.

virtual const char* what() const throw() {}
Christian Hackl
  • 27,051
  • 3
  • 32
  • 62
user306078
  • 51
  • 2
  • Regarding reading, [here's an excellent list](http://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list). More specifically, read about *virtual functions* and *polymorphism*, together with *exceptions*. – Some programmer dude Jan 15 '17 at 11:27
  • 6
    `throw()` is not a function, it is a keyword. [Relevant Q&A](http://stackoverflow.com/q/1055387/335858). – Sergey Kalinichenko Jan 15 '17 at 11:29
  • 2
    ^ - A keyword deprecated in recent standard versions. Use `noexcept` or nothing at all in its stead. – StoryTeller - Unslander Monica Jan 15 '17 at 11:30
  • 2
    I'm upvoting this because for a beginner, that's actually a very genuine question. C++ declaration syntax is hard and *"two functions in the same declaration"* may be a common thought (and thus a common search term on Google) when such code is seen for the first time. – Christian Hackl Jan 15 '17 at 11:39
  • @dasblinkenlight: I think you should just turn this comment into an answer. – Christian Hackl Jan 15 '17 at 11:58

0 Answers0