Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6953389
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:28:21+00:00 2026-05-27T14:28:21+00:00

Could anyone explain to me this definition of standard exception in C++: virtual const

  • 0

Could anyone explain to me this definition of standard exception in C++:

virtual const char* what() const throw();

What does const throw() mean at the end?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T14:28:22+00:00Added an answer on May 27, 2026 at 2:28 pm

    These are separate issues.


    Regarding const

    From the standard (if too long, only read the bold parts):

    Nonstatic member functions

    […] A non-static member function may be declared const, volatile, or const volatile. These cv-qualifiers
    affect the type of the this pointer (9.3.2). They also affect the function type (8.3.5) of the member function;
    a member function declared const is a const member function, a member function declared volatile is
    a volatile member function and a member function declared const volatile is a const volatile member
    function. […]

    The this pointer

    […] In a const member function, the object for which the function is called is accessed through a const access
    path; therefore, a const member function shall not modify the object and its non-static data members. […]

    Storage class specifiers

    […] The mutable specifier on a class data member nullifies a const specifier applied to the containing class object
    and permits modification of the mutable class member even though the rest of the object is const (7.1.6.1).

    Summary: A member function qualified with const is not allowed to change any member that is not declared mutable. The reason for mutable is that even if an object is const, mechanism like caching can be done; it is good practice that the observable behavior of an object does not change by calling const member function.


    Regarding throw()

    Exception specifications [expect.spec]

    A function declaration lists exceptions that its function might directly or indirectly throw by using an
    exception-specification as a suffix of its declarator.

    More specifically, it is a dynamic-exception-specification, and a

    […] function is said to allow an exception of type E if its dynamic-exception-specification contains a type T for
    which a handler of type T would be a match (15.3) for an exception of type E.

    In other words, the types within ( and ) are the exceptions that this function might throw. However, it is common practice to not use non-empty dynamic exception specifications for some good reasons.

    Using throw(), i.e. an empty exception list, in pre-C++11 was accepted practice to annotate functions that never throw. However, as of C++11, the current standard, one should use noexcept instead.

    Also, as of C++11,

    [ Note: The use of dynamic-exception-specifications is deprecated (see Annex D). —end note ]

    so use noexcept instead.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Could anyone explain exactly what this method does in AndEngine? runOnUpdateThread(new Runnable() { @Override
I was wondering if anyone could explain what this rule is saying: <IfModule mod_rewrite.c>
I was wondering if anyone could explain this to me: <%@ Page Title=Log In
Could anyone please explain why this may be happening? Image is here Image I
Could anyone explain why this won't compile? This loop keeps moving the ref. 'person'
Could anyone explain this to me? I've seen quite a few DateFormatter issues around,
Could anyone please explain this to me with an example? I am getting contradicted
Could anyone explain to me in noob way what the difference is betweeen ImageIcon
Could anyone explain why $property is 'name' outside of the function and null inside?
Possible Duplicate: Could anyone explain these undefined behaviors (i = i++ + ++i ,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.