Skip to content

Correct the documentation for raw pointers. #3605

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

neonbhai
Copy link

@neonbhai neonbhai commented Dec 22, 2021

Fixed the third code example. line 37 demonstrates declaring a non-const pointer but actually declared a const pointer. Deleted 'const' keyword from line 37.

line 37 demonstrated declaring a non-const pointer but actually declared a const pointer
@PRMerger20
Copy link
Contributor

@neonbhai : Thanks for your contribution! The author(s) have been notified to review your proposed change.

@neonbhai neonbhai changed the title Fixed the third code example. line 37 demonstrates declaring a non-const pointer but actually declared a const pointer. Correct the documentation for raw pointers. Dec 22, 2021
@ktoliver
Copy link
Contributor

#label:"aq-pr-triaged"

@PRMerger-2 PRMerger-2 added the aq-pr-triaged Tracking label for the PR review team label Dec 22, 2021
@colin-home
Copy link
Contributor

@neonbhai
Sorry about taking so long to get back to you; I've been on vacation for the last two weeks. Thanks for taking time to work on improving the docs. Unfortunately, while I appreciate your efforts here, your change isn't correct and leads to a compiler error:

error C2440: 'initializing': cannot convert from 'const int *' to 'int *'

Pointers to int are declared like so, depending on constness and East-const or West-const preference:

int is const Pointer is const Declaration
No No int i = 42; int * p_i = &i;
No Yes int i = 42; int * const kp_i = &i;
Yes No int const ki = 42; int const * p_ki = &ki; // "East const"
const int ki = 42; const int * p_ki = &ki; // "West const"
Yes Yes int const ki = 42; int const * const kp_ki = &ki; // "East const"
const int ki = 42; const int * const kp_ki = &ki; // "West const"

I hope this illustrates why I'm closing your PR unmerged.

@colin-home colin-home closed this Jan 4, 2022
Xazax-hun pushed a commit to Xazax-hun/cpp-docs that referenced this pull request Feb 23, 2022
…e-3181

/external not experimental in 16.10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants