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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T20:11:29+00:00 2026-05-12T20:11:29+00:00

NOTE: I know there are many questions that talked about that but I’m still

  • 0

NOTE: I know there are many questions that talked about that but I’m still a beginner and I couldn’t understand the examples.

I got a function prototype that goes like this:

int someFunction(const char * sm);

Here, as you know, const char* means that this function can accept const or non-const pointer-to-char. I tried something like that in the function body:

someMemberVar = sm;

someMemberVar is just a pointer-to-char. The compiler gives me an error telling me:
cannot convert from const char* to char*.

Here, I didn’t pass a constant, so either sm or someMemberVar aren’t constants. So, what constant the compiler is talking about?

  • 1 1 Answer
  • 2 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-12T20:11:30+00:00Added an answer on May 12, 2026 at 8:11 pm

    I’ll try to put in simpler terms what others are saying:

    The function someFunction takes a read-only string (for simplicity’s sake, though char * could be used in umpteen other cases). Whether you pass in a readonly string to someFunction or not, the parameter is treated as read-only by the code executing in the context of this function. Within this function therefore, the compiler will try to prevent you from writing to this string as much as possible. A non-const pointer is such an attempt to disregard the read-only tag to the string and the compiler, rightly and loudly informs you of such disregard for its type system 😉

    What’s the difference between: int someFunction(const char * sm) const{…} and this: int someFunction(const char * sm){…}

    The first is a function which takes a readonly parameter. The second const written after the closing parentheses is valid only for member functions. It not only takes a read-only parameter, but also gurantees to not alter the state of the object. This is typically referred to as design level const.

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

Sidebar

Related Questions

Note : I know there are many questions related to this, but still I
Please note that I'm not asking how but why. And I don't know if
There seem to be many many unanswered questions about this. Hopefully, I'll get lucky
Note: I know this is wrong , but this is a technical requirement by
Note: this is NOT about concurrency. This is about the thread macro. I know
IMPORTANT NOTE: I recieved many answers and I thank you all. But all the
There are other questions about this in other languages , and other non-lazy JavaScript
There is a test that consists of 12 questions. each question must have a
Note: Version 2, below, uses the Sieve of Eratosthenes. There are several answers that
NOTE: I am aware of the SVN relocate switch, I just need to know

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.