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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:07:51+00:00 2026-05-28T07:07:51+00:00

In C++ it is not allowed to assign an void* pointer to any integral

  • 0

In C++ it is not allowed to assign an void* pointer to any integral pointer without an explicit cast. This requires the use of an static_cast.

But what is with this:

int* iptr = new int;

I know that new operator is defined as following:

void* operator new(size_t);

How does C++ handle this?
I know that this is a basic question, but important. I also know that low-level code must use void. But how can this assignment be legal? iptr is a pointer to an int and new returns a pointer to void, which should trigger a message like “error: invalid conversion from ‘void*’ to ‘int*’ [-fpermissive]”.

  • 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-28T07:07:52+00:00Added an answer on May 28, 2026 at 7:07 am

    You have confused the new operator and the operator new function. No problem, everybody does. They are almost the same, except that they are different.

    The function void* operator new(size_t) grabs a block of raw, untyped memory from whatever tree it grows on, and returns it to the program.

    void* raw_memory = ::operator new(42);
    

    It is an ordinary function with somewhat weird name.

    The new operator is not a function and not a function call. It’s a separate language construct. It takes raw memory (normally, one returned by the void* operator new(size_t) function) and turns it into an object by calling a constructor. It then returns a properly typed pointer to the newly-created object.

    Fish* f = new Fish;
    

    UPDATE Naturally, there is also the delete operator (the opposite of the new operator) and the void operator delete(void*) function (the opposite of the void* operator new(size_t) function).

    There are also the new[] operator, the delete[] operator, the void* operator new[](size_t) function, and the void operator delete[](void*) function; they deal with arrays of objects (as opposed to individual objects).

    There are also so-called “placement new” forms that do not call any of the operator new functions for fresh memory, but instead require an explicit pointer to raw memory. They have no corresponding built-in “delete” forms. You can roll your own if you are so inclined, but I refuse to talk about any of this while being sober.

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

Sidebar

Related Questions

In XHTML Strict, it seems that you're not allowed to use the <u> tag
This should really be allowed - I do not understand why it is not.
i want to assign multiple resources (engineers) to the same sprint. But, not able
Why it is not allowed to assign null to a DateTime in C#? How
As you know, it is not allowed to use the Array-initialisation syntax with Lists.
I know that this will not work, but hopefully you can see what I'm
I know it is not allowed in C++, but why? What if it was
why c# not allowed operator overloading while C++ do? I got this error, when
In .net we are not allowed to have shared function/methods in abstract classes and
Primitive types are not allowed in ArrayList, source . Partial solution: you can wrap

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.