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 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.
The title says it! I know that Jon Skeet was working on an implementation
As the title says, I'm trying to do something like this: public abstract class
Like the title says, I just need something to migrate a set of tables
As title says, is there any way to pull something like this up?: std::set<boost::shared_ptr<MyClass>>
Well title says all I guess. I've tried to print_r($_SERVER) but my 'post-request' I
As title says. I am looking for some help with my .htaccess. I have
As the title says. Where do they go? they're variables, but they're also code...
The Title says everything.. Searched Google and Stackoverflow and didn't find something similiar..
Like the title says, I can't get Canvas/CanvasLayer working in PlayN. My sample code

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.