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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T09:38:21+00:00 2026-05-26T09:38:21+00:00

I have a class A whose objects are created dynamically: A *object; object =

  • 0

I have a class A whose objects are created dynamically:

A *object;
object = new A;

there will be many objects of A in an execution.
i have created a method in A to return the address of a particular object depending on the passed id.

A *A::get_obj(int id)

implemetation of get_obj requires itteration so i chose vectors to store the addresses of the objects.

vector<A *> myvector

i think another way to do this is by creating a file & storing the address as a text on a particular line (this will be the id).
this will help me reduce memory usage as i will not create a vector then.
what i dont know is that will this method consume more time than the vector method?
any other option of doing the same is welcome.

  • 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-26T09:38:22+00:00Added an answer on May 26, 2026 at 9:38 am

    will this method consume more time than the vector method?

    Yes, it will consume a lot more time – every lookup will take several thousand times longer. This does not hurt if lookups are rare, but if they are frequent, it could be bad.

    this will help me reduce memory usage

    How many object are you expecting to manage this way? Are you certain that memory-usage will be a problem?

    any other option of doing the same is welcome

    These are your two options, really. You can either manage the list in memory, or on disk. Depending on your usage scenario, you can combine both methods. You could, for instance, keep frequently used objects in memory, and write infrequently used ones out to disk (this is basically caching).

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

Sidebar

Related Questions

I have a class whose object must be created on the heap. Is there
Say I have a Class object which represents an anonymous inner class. Is there
i have a class whose equality is based on 2 fields such that if
We have a class whose semantic behaviour is like the following :- struct Sample
I have a class whose constructor takes a const reference to a string. This
I have a class whose functionality I'd like to depend on a set of
I have a CurrentUser class with a static property whose value was stored in
Suppose I have a file X.h which defines a class X, whose methods are
I have a Struts + Velocity structure like for example, a Person class, whose
I have class method that returns a list of employees that I can iterate

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.