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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T20:42:41+00:00 2026-05-16T20:42:41+00:00

This is kind of basic but I can’t seem to get a hold on

  • 0

This is kind of basic but I can’t seem to get a hold on this one. Reference here

Are void *p and const void *p sufficiently different? Why would a function use const void * instead of void *?

  • 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-16T20:42:41+00:00Added an answer on May 16, 2026 at 8:42 pm

    The reason to use void* at all (whether const or not) is the kind of genericity it provides. It’s like a base class: All pointers are void* and can implicitly cast into it, but casts from void* to typed pointers have to be done explicitly and manually.

    Usually, C++ has better ways to offer to do this (namely OO and templates), so it doesn’t make much sense to use void* at all, except when you’re interfacing C. However, if you use it, then const offers just what it offers elsewhere: you need an (additional) const_cast to be able to change the object referred to, so you are less likely to change it accidentally.

    Of course, this relies on you not employing C-style casts, but explicit C++ casts. The cast from void* to any T* requires a static_cast, and this doesn’t allow removing of const. So you can cast const void* to const char* using static_cast, but not to char*. This would need an additional const_cast.

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

Sidebar

Related Questions

I know questions of this kind have been asked before, but my situation differs
I have ask this kind of question before, but it seems my previous question
Here's a coding problem for those that like this kind of thing. Let's see
Kind of a basic question but I'm having troubles thinking of a solution so
I am sure that this kind of questions must have been asked before, but
I'm not sure if this is even possible, but here goes: I have a
this kind of follows on from another question of mine. Basically, once I have
I have this kind of code in some applications (from microsoft) [assembly: System.Diagnostics.CodeAnalysis.SuppressMessage( Microsoft.Naming,
My stomach churns when I see this kind of output. http://www.freeimagehosting.net/uploads/e1097a5a10.jpg and this was
I have a file that contains this kind of paths: C:\bad\foo.c C:\good\foo.c C:\good\bar\foo.c C:\good\bar\[variable

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.