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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T15:56:51+00:00 2026-05-25T15:56:51+00:00

Does it allow the compiler to inline it, knowing that only functions in the

  • 0

Does it allow the compiler to inline it, knowing that only functions in the same class can access it? Or is it only for the programmer’s convenience?

  • 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-25T15:56:51+00:00Added an answer on May 25, 2026 at 3:56 pm

    The compiler can (but is not required to) optimize as you suggest, but that’s not the point. The point of access modifiers is to catch certain classes (no pun intended) of programming errors at compile time. Private functions are functions that, if someone called them from outside the class, that would be a bug, and you want to know about it as early as possible.

    (Any time you ask the question “could the compiler make optimizations based on this information available to it”, the answer is “yes, unless there’s a specific rule in the standard that says it’s not allowed to” (such as the rules for volatile, whose entire purpose is to inhibit optimizations). However, compilers do not necessarily bother optimizing based on any given piece of information. There is, after all, no requirement for compilers to do any optimization in the first place! How clever your compiler is, nowadays, largely depends on how long you are willing to let it run; MSVC’s whole-program PGO mode is capable of inlining through virtual method dispatch — it guesses the most likely target, and falls back to a regular virtual call at runtime if the guess was wrong — but slows down compiles by at least a factor of two.)

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

Sidebar

Related Questions

Is there any html form class(text box) that does not allow null values. The
Since AS3 does not allow private constructors, it seems the only way to construct
C++ doesn't allow a class containing an array of items that are not default
Why C# compiler does not allow you to compile this: int a; Console.WriteLine(a); but
unique_ptr<T> does not allow copy construction, instead it supports move semantics. Yet, I can
Is this possible? If it is, how? And if not, which compiler that does
Does cygwin allow a statically compiled binary? This would prevent the need for cygwin1.dll
Does C# allow hashtables to be populated in one-line expressions? I am thinking of
IE does not allow writing to the innerHTML property of style or head elements.
C++ does not allow polymorphism for methods based on their return type. However, when

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.