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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:27:28+00:00 2026-05-25T15:27:28+00:00

As title says, I’m currently doing some small hacks with pointers in C++, but

  • 0

As title says, I’m currently doing some small hacks with pointers in C++, but something isn’t working out here’s what I got:

uintptr_t texture_pointer = (int)((void*) &texture);

Where texture is a class; this seems to work fine, as I’m getting a pointer value out, and I have insured that I’m getting the same value into my other function, which is supposed to get the object back; this is the code that fails:

std::cout << "C++ BEFORE: " << texture_pointer << std::endl;
Texture texture = *(Texture*)((void*) texture_pointer);
std::cout << "C++ AFTER: " << (uintptr_t)((void*) &texture) << std::endl;

The output I was excepting; was that the same number for both, however I’m getting two different numbers, hence why I think there must be an error, but I can’t seem to find it.

Example output:

C++ BEFORE: 2685236
C++ AFTER: 2684960
  • 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-25T15:27:29+00:00Added an answer on May 25, 2026 at 3:27 pm

    This line:

    Texture texture = *(Texture*)((void*) texture_pointer);
    

    creates a new Texture object as a copy of the original one. Obviously, this has a different address to the old one.

    You could do this:

    Texture &texture = *(Texture*)((void*) texture_pointer);
    

    (i.e. create a reference to the old one).

    But in general, messing about with pointers like this is more trouble than it’s worth.

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

Sidebar

Related Questions

The title says everything, but just to be clear I'll add some extra words.
Pretty much what the title says really. We have some code that is .NET
As the title says, I cannot get padding around the text. Here's my xml:
Well title says all I guess. I've tried to print_r($_SERVER) but my 'post-request' I
The Title says everything.. Searched Google and Stackoverflow and didn't find something similiar..
Title says what i'm trying to do. I can successfully generate an assembly if
Title says it mostly. I want to add a simple extension method to the
Question title says it all really - a lot slower than VS2005, with a
As title says, how do I call a java class method from a jsp,
Just what the title says, I need to change the password for an existing

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.