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

  • Home
  • SEARCH
  • 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 7945113
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T00:45:33+00:00 2026-06-04T00:45:33+00:00

Why is following not allowed in C++ #include <iostream> class Sample { public: void

  • 0

Why is following not allowed in C++

#include <iostream>

class Sample {
public:
  void Method(char x);
  void Method(char const x);
};

void Sample::Method(char x) {
  char y = x;
}

void Sample::Method(char const x) {
  char y = x;
}

int main() {
  Sample s;
  return 0;
}
  • 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-04T00:45:35+00:00Added an answer on June 4, 2026 at 12:45 am

    It doesn’t really answer why, but it is determined by the standard, §1.3.10

    The information about a function that participates in overload resolution (13.3): the types of its parameters
    and, if the function is a class member, the cv- qualifiers (if any) on the function itself and the class in which the member function is declared.

    This just means the cv qualifiers of the arguments are ignored in the overload resolution.

    A similar (but not equivalent) example with references works:

    class Sample {
    public:
      void Method(char& x) {}
      void Method(const char& x) {}
    };
    

    because here the types are different, the first case being a reference to char, the second a reference to const char (as opposed to a const reference to char).

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

Sidebar

Related Questions

When I try compiling the following: #include <iostream> class Test { public: void* operator
Why something like following is not allowed. I mean why the following method will
Why does the following not work: #include <iostream> #include <fstream> #include <stack> std::stack<std::ifstream> s;
The following does not compile: class Foo { public: Foo( boost::shared_ptr< Bar > arg
As the following error implies, calling a host function ('rand') is not allowed in
Why does the following not give an error? for (int i=0; i<10; ++i) //
The following class is not thread-safe (as proven in Proving the following code not
I'm very surprised to find that the following compiles: #include <iostream> using namespace std;
I read some code written in c++ as following: #include <algorithm> #include <iostream> #include
I have the following situation (simplified): a.h: #include <boost/serialisation/serialisation.hpp> class B; using namespace std;

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.