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 7840225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T15:42:28+00:00 2026-06-02T15:42:28+00:00

I heard that volatile is factor of overloading like const. If a function is

  • 0

I heard that volatile is factor of overloading like const.

If a function is overloaded by volatile parameter,
when is the volatile-version called?

I can’t imagine a situation when the volatile-version is called. 

  • 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-06-02T15:42:30+00:00Added an answer on June 2, 2026 at 3:42 pm

    Volatile can be applied to parameters, but it is not a factor of overloading when applied directly to the parameter. It is however possible to use it to distinguish types of the parameter. For example, this is legal:

    void f(int &p) {}; //reference to int
    void f(volatile int &p) {}; //reference to volatile int
    

    This is not:

    void f(int p) {};
    void f(volatile int p) {};
    

    The reason is that in the first example the reference is not what is volatile, but the integer. In the second example, both types are integers and therefore the same type.

    There are also volatile methods. They are akin to declaring this to be volatile. Because this is a pointer and not the containing type itself, the following is also legal:

    void c::f(int p) {};
    void c::f(int p) volatile {};
    

    It is all the same as for overloading by const.

    This relevant part of the C++ standard is §13.1 Overloadable declarations. From C++11 draft n3290:

    Parameter declarations that differ only in the presence or absence of const and/or volatile are equivalent. That is, the const and volatile type-specifiers for each parameter type are ignored when determining which function is being declared, defined, or called. [ Example:

    typedef const int cInt;
    int f(int);
    int f(const int);          // redeclaration of f(int)
    int f(int) { /* ... */ }   // definition of f(int)
    int f(cInt) { /* ... */ }  // error: redefinition of f(int)
    

    — end example ]

    Only the const and volatile type-specifiers at the outermost level of the parameter type specification are ignored in this fashion; const and volatile type-specifiers buried within a parameter type specification are significant and can be used to distinguish overloaded function declarations124. In particular, for any type T, pointer to T, pointer to const T, and pointer to volatile T are considered distinct parameter types, as are reference to T, reference to const T, and reference to volatile T.

    124) When a parameter type includes a function type, such as in the case of a parameter type that is a pointer to function, the
    const and volatile type-specifiers at the outermost level of the parameter type specifications for the inner function type are
    also ignored.

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

Sidebar

Related Questions

I heard that volatile nature of a variable can be removed using const_cast operator.
I heard that calling a handler (delegate, etc.) in Objective-C can be even faster
I heard that PKCS#1 v2.0 encryption is usually called OAEP encryption. I'll need some
Possible Duplicate: Is volatile expensive? I heard that using volatile variable in multithreaded application
I heard that there is a mechanism to deliver ad-hoc version app for client
I heard that SQL Injection can still be possible when using ADO.NET SQLParameter (paramterised
I heard that its not advised to use % in the beginning of LIKE
I heard that minecraft server is very leaky, can consume a lot of resources
I heard that computation results can be very sensitive to choice of random number
I heard that Event Espresso can do anything that the Eventbrite do. But 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.