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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:01:15+00:00 2026-05-28T02:01:15+00:00

I understand that a const pointer can be declared a couple ways: const int

  • 0

I understand that a const pointer can be declared a couple ways:

const int * intPtr1; // Declares a pointer that cannot be changed.
int * const intPtr2; // Declares a pointer whose contents cannot be changed.

// EDIT: THE ABOVE CLAIMS ARE INCORRECT, PLEASE READ THE ANSWERS.

But what about the same principles within the context of function arguments?

I would assume that the following is redundant:

void someFunc1(const int * arg);
void someFunc2(int * arg);

Since someFunc 1 and 2 do a pass-by-value for the pointer itself, its impossible for someFunc1 to change the value of the original pointer, in a given call to the function. To illustrate:

int i = 5;
int * iPtr = &i;

someFunc1(iPtr); // The value of iPtr is copied in and thus cannot be changed by someFunc1.

If these are true, then there is no point in ever declaring a function with a ‘const int * ptr’ type arg, correct?

  • 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-28T02:01:15+00:00Added an answer on May 28, 2026 at 2:01 am

    You have it backwards:

    const int * intPtr1; // Declares a pointer whose contents cannot be changed.
    int * const intPtr2; // Declares a pointer that cannot be changed.
    

    The following const is indeed unnecessary, and there’s no reason to put it in a function declaration:

    void someFunc1(int * const arg);
    

    However, you might want to put it in the function implementation, for the same reason that you might want to declare a local variable (or anything else) const – the implementation may be easier to follow when you know that certain things won’t change. You can do that whether or not it’s declared const in any other declarations of the function.

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

Sidebar

Related Questions

According to the following program, I can understand that, const keyword at a front
I understand that there are several ways to blend XNA and WPF within the
There are a couple of things that I don't understand about the function pthread_create
I've often used pointers to const objects, like so... const int *p; That simply
I understand that static_cast can convert between base and derived and between derived and
I can't figure out how to tell C that I want a pointer that
qsort(bt->rw[t], bt->num[t], sizeof(TRELLIS_ATOM *), (int (*)(const void *,const void *))compare_wid); bt->rw[t] is a pointer
I understand that const_cast to remove constness of objects is bad, I have the
I understand that some countries have laws regarding website accessibility. In general, what are
I understand that they are both supposed to be small, but what are the

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.