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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T23:27:37+00:00 2026-05-10T23:27:37+00:00

void some_func(int param = get_default_param_value());

  • 0
void some_func(int param = get_default_param_value()); 
  • 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. 2026-05-10T23:27:37+00:00Added an answer on May 10, 2026 at 11:27 pm

    Default parameter can be a subset of the full set of expressions. It must be bound at compile time and at the place of declaration of the default parameter. This means that it can be a function call or a static method call, and it can take any number of arguments as far as they are constants and/or global variables or static class variables, but not member attributes.

    The fact that it is bound at compile time and in the place where the function is declared also means that if it makes use of a variable, that variable will be used even if a different variable shadows the original at the place of the function call.

    // Code 1: Valid and invalid default parameters int global = 0; int free_function( int x );  class Test { public:    static int static_member_function();    int member_function();     // Valid default parameters    void valid1( int x = free_function( 5 ) );    void valid2( int x = free_function( global ) );    void valid3( int x = free_function( static_int ) );    void valid4( int x = static_member_function() );     // Invalid default parameters    void invalid1( int x = free_function( member_attribute ) );     void invalid2( int x = member_function() ); private:    int member_attribute;    static int static_int; };  int Test::static_int = 0;  // Code 2: Variable scope int x = 5; void f( int a ); void g( int a = f( x ) ); // x is bound to the previously defined x void h() {    int x = 10; // shadows ::x    g(); // g( 5 ) is called: even if local x values 10, global x is 5. } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 63k
  • Answers 63k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The event bubbles up, until it gets handled... Since the… May 11, 2026 at 10:21 am
  • added an answer You could make your enums implement an interface, then give… May 11, 2026 at 10:21 am
  • added an answer Import the WheelParticle class (along with every other class you… May 11, 2026 at 10:21 am

Related Questions

void some_func(int param = get_default_param_value());
This code leads to undefined behavior: void some_func() { goto undefined; { T x
Say we have: class Base { virtual void f() {g();}; virtual void g(){//Do some
I have some classes layed out like this class A { public virtual void
OK so I'm looking a some code which looks roughly like this: void DoSomething(object
void (int a[]) { a[5] = 3; // this is wrong? } Can I
void addNewNode (struct node *head, int n) { struct node* temp = (struct node*)
void foo(void **Pointer); int main () { int *IntPtr; foo(&((void*)IntPtr)); } Why do I
private void activateRecords(long[] stuff) { ... api.activateRecords(Arrays.asList(specIdsToActivate)); } Shouldn't this call to Arrays.asList return
public void test() { List<int> list = new List<int>(); list.Add(1); list.Add(2); list.Add(3); for (int

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.