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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:00:21+00:00 2026-06-06T13:00:21+00:00

Can i make an object in C++ specifying its memory address explicitly? This is

  • 0

Can i make an object in C++ specifying its memory address explicitly? This is because i am having separate ids for each of my entities (the objects). So if i can do this, i will be able to traverse through all my objects by mere pointer additions.
Consider:
I have an object with memory location x.
I want to create the next object with memory location x+(the unique id of the next object)*K
where K is the constant gap between two objects(say)

  • 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-06-06T13:00:22+00:00Added an answer on June 6, 2026 at 1:00 pm

    You can specify the memory using the placement new operator.

    So if i can do this, i will be able to traverse through all my objects by mere pointer additions.

    Not really. Disregard answers that tell you to do this! You can’t do pointer arithmetics outside of an array. Just because you have 2 objects o1 and o2, one located at 0x4 and the other at 0x5, it doesn’t mean that &o1 + 1 will yield &o2. In fact, it’s undefined behavior.

    For this to work as expected, you can allocate the memory dynamically, or, better yet, use a std::vector and use iterators. (that’s what they are for)

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

Sidebar

Related Questions

How can I make an object rotate around its axis? i.e. having the moon
Since there is no way that you can make the flash object transparent, there
How can i make a cached object re-cache it self with updated info when
How can I make a NinePatchDrawable object from a NinePatch image I made in
How can I make a ForeignKey refer back to the object itself? I'm trying
Given an instantiated JavaScript object/class can I make an Ajax call from that class
I'm trying to make getJSON to use JSONP object, but I can't figure out
I know that by implementing iterable you can make an object able to be
I have: var datatime = '2012-01-25 07:44:00'; How can i make object Datatime with
Someone ask me that do we make an object of class having private constructor

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.