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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:00:43+00:00 2026-05-25T21:00:43+00:00

I think this is a really newb question, but I never found out the

  • 0

I think this is a really newb question, but I never found out the answer. I don’t know how exactly to phrase this question, but I often find that I have to access objects that are “far away” from the current object in terms of the current hierarchy. I just want to make sure that this is the right (only) way to do this.

This goes along with passing parameters in from main also. I find that some objects far away from main need to be passed in with a parameter multiple times. How does an object far away from main get information from the command line?

For example for the first case, for 4 classes…

class A{
   B b;
   //need to check status of D

   //choice 1
   b.get_c().get_d().get_status();  

   //choice 2
   const C& c = b.get_c();
   const D& d = c.get_d();
   d.get_status();
};

class B{
public:
   C c;
   const C& get_c() {return c;}
};

class C{
public:
   D d;
   const D& get_d() {return d;}
};

class D{
public:
   bool check_status();
};

Say something like, A is car, B is door assembly, C is door, D is lock. Then A has to check say, is lock on, otherwise prevent starting.

Choice 3 is to directly call D’s method from A, I’d have to make a few layers of check_status() in C, B, and A and return D, C, B.check_status().

Don’t all these calls to subobjects (if the code was a bit more complicated) get a lot of overhead?

Thanks.

  • 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-25T21:00:44+00:00Added an answer on May 25, 2026 at 9:00 pm

    The answer to this sort of question is always the same: Don’t worry about it unless and until it becomes a problem, and then, take measurements to decide which option is best. Yes, there’s an overhead with calls to subobjects but with the example you’ve given (and with many real-life examples) this overhead is unavoidable (and the compiler may optimize some of it away anyway).

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

Sidebar

Related Questions

This is for an iPhone App, but I don't think that really matters. I
i didn't really know how to title this question, but here's a thing that
I think this maybe a really dumb question, but i just want to be
I feel like the answer to this question is really simple, but I really
I know Linq-to-SQL is dead, but anyway, I think this is really basic, I'm
I think this question is really about my understanding of Garbage collection and variable
EDIT: This question was initially too general, I think. So What I really need
I think this is likely to be a generic .NET assembly loading question, but
I think this is really simple, but I can't get my head around it.
This is probably quite a newb question, but I can't seem to figure it

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.