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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T20:08:40+00:00 2026-06-17T20:08:40+00:00

First question: Many times we pass a reference of one object to another via

  • 0

First question:

Many times we pass a reference of one object to another via function call using pointers.For example:

int num =25;
int *num1Ptr=#
int *num2Ptr=NULL;

void assinNum (int *numPtr){

    num2Ptr = numPtr; ////we copy the value (address) of the num1Ptr pointer to num2Ptr
}

My question is : if such a method gets called very frequently can we expect a significant overhead of pointers copy?

Second question :

In the following scenario , does it mean we copy the value in the memory address pointed by passed numPtr to the memory address pointed by num2Ptr? If yes ,then it is the same as passing by value ?

int num =25;
int *num1Ptr=#
int *num2Ptr=NULL;

void assinNum (int *numPtr){

    *num2Ptr = *numPtr; ////num2Ptr points to the same value in the memory pointed by numPtr argument. 
}

Update for the first question:

What are the consequences for the pointers to large objects (not primitives)?

  • 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-17T20:08:41+00:00Added an answer on June 17, 2026 at 8:08 pm

    if such a method gets called very frequently can we expect a significant overhead of pointers copy?

    A pointer is usually just a 32-bit or 64-bit quantity. So copying a pointer just involves copying a 32-bit or 64-bit quantity, which is very cheap on most platforms. However, copying an int directly is also very cheap, so in this case, using pointers probably doesn’t bring you much benefit.

    It’s also worth pointing out that in many situations, the compiler will optimize this function by inlining it.

    does it mean we copy the value in the memory address pointed by passed numPtr to the memory address pointed by num2Ptr?

    In theory, yes. However, num2Ptr = NULL, so your code is likely to cause a segmentation fault.

    then it is the same as passing by value ?

    I’m not sure what you’re referring to, so it’s difficult to know how to answer this!

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

Sidebar

Related Questions

though I have visited this site many times, this is my first question. After
This is my first question on this site, having used it many times to
First of all, I am aware that this question has been discussed many times
Ok, my first question was modified so many times that I chose to delete
It's my first question on SO. I know that there were many topics on
Many times when I've written stored procedures, etc. I use a CURSOR at first
I have a general question about this. There are many times we want to
I see that this question has been asked many times but I think my
This question has been asked many times before, but they all seem to relate
I know this question is asked many a times,and i am also implementing the

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.