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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:45:48+00:00 2026-05-19T22:45:48+00:00

I’m working on a project where several different object are semantically linked together and

  • 0

I’m working on a project where several different object are semantically linked together and I’m now looking for a good way to let the objects refer to each other. Usually I would put pointers in each object and link them together. In this special case there are no heap objects (at least I do not create any while writing the code, what a vector does internally might be on another page). We came up with the idea to have a class that stores a list of unique ids and share this id with the objects that need them to known.

Is this good practice? Are there other, better ways to do this?

Background: The project is settled in an academic background. We do not definitely know what students or other people contribute to this. Also the skill level is not known, but probably not very high. By not using pointers we can at least ensure that objects are not deleted accidentally or out of stupidity.

Edit:

What led me to the idea of a unique id was our usage of vectors to store the data. One thing that STL containers do a lot is copying their containees. This is why I’m not so sure that pointers would work well. Same with simple indices of the vector elements, the content and/or it’s order might change.

  • 1 1 Answer
  • 3 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-19T22:45:48+00:00Added an answer on May 19, 2026 at 10:45 pm

    Is this good pratice?

    In my experience, no. Any sort of unique ID crap is just one more thing that has to be managed, and managed correctly or you’ll get all kinds of weird bullshit spraying all over. I worked on a product once that used this idea and a good portion of our bugs, and even more maintenance problems, was caused by having to remember about the stupid ID tracking variable. Granted, the implementation was quite convoluted (borderline insane) and it’s very easy to do better than was being done, but it’s still just one more thing to deal with when you already have a unique ID generated by the system: the address of the variable.


    Are there other, better ways to do this?

    Yeah, use pointers.

    Unfortunately there’s no such thing as a smart pointer (that I know of anyway) that can be used to simply refer to objects owned elsewhere so for now, you have to make sure to enforce the issue through policy and documentation. It’s a weakness, yes, but still a much better alternative to tracking and ID, which can just as easily have the same problems and more.

    If you’re interested in smart pointers that can be used for such purposes you might be interested in my latest blog entry.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
i got an object with contents of html markup in it, for example: string
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.