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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T00:28:05+00:00 2026-06-17T00:28:05+00:00

Taking this as an example: I have 20 structs. I access all of the

  • 0

Taking this as an example:

I have 20 structs. I access all of the struct’s fields directly, getting values off them, pointers to other sub-structs they might have, etc.

Now, I restructure the program:
Instead of acessing structs’s fields DIRECTLY, I’ve encapsuled all of the struct into their own respective classes, and have functions for all the possible get(), and set(x).

The Question: Is there a performance impact for using methods/functions, instead of acessing structs directly?

Some sort of estimated % would be great, or some explanation.

  • 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-17T00:28:06+00:00Added an answer on June 17, 2026 at 12:28 am

    In general, there shouldn’t be a performance difference if the getters and setters are defined inline within the class. For virtually any contemporary compiler, the function call will be expanded inline, leaving no overhead. This will often be true for various small inline functions. (See, for example, http://www.gotw.ca/publications/mill18.htm, where Herb Sutter discusses why making most/all virtual functions nonpublic adds no overhead to the resulting code.)

    Note that if you do define the function inline in the class, any client code will need to be recompiled if the definition ever changes. But that applies to most/all changes in header files.

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

Sidebar

Related Questions

jquery.ui.position is not taking the margin values when positioning items? I have this example,
Taking this file as an example, I'm trying to read the data in a
Taking the jQuery framework for example, if you run code like this: $(document).ready(function init()
Taking this simplifed example of my XML: <?xml version=1.0?> <message xmlns=http://www.mydomain.com/MyDataFeed xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http://www.mydomain.com/MyDataFeed https://secure.mydomain/MyDataFeed/myDataFeed.xsd
I have a matlab plot that looks like this: Where the Y values for
Talking about structs, is it possible to just copy a struct 's fields to
I have this struct typedef struct grade { char firstName[SIZE]; char lastName[SIZE]; int stuNum;
Given a list with a statically typed length (taking this as an example): data
getting a bit confused over this problem... I have an administrative part of my
This jsfiddle example shows what I'm talking about, I gave the div in question

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.