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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T18:17:25+00:00 2026-05-12T18:17:25+00:00

Edited this question because of my bad examples.. Here is my updated question: Would

  • 0

Edited this question because of my bad examples.. Here is my updated question:

Would the following be equal in speed and memory allocation:

int b;
for (int i = 0; i < 1000; i++)
    b = i;

and

for (int i = 0; i < 1000; i++)
    int b = i;
  • 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-12T18:17:25+00:00Added an answer on May 12, 2026 at 6:17 pm

    No, it wouldn’t.

    In the first case you’ve got one variable being assigned 1000 different values – and you end up being able to get hold of the last value (999) after the constructor has completed.

    In the second case you’re calling an essentially no-op method 1000 times. The second method has no side-effects and has no return value, so it’s useless. The local variable only “exists” for the duration of the method call, whereas the instance variable in the first example is part of the object, so will live on.

    Note that this isn’t restricted to primitives – any other type would behave the same way too.

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

Sidebar

Related Questions

Asking this question because I feel that member variables of my base will be
Good night everyone, This question leaves me a little embarassed because, of couse, I
** Question edited ** Here's a typical Makefile template : TARGET = my_prog #
This is a sample (edited slightly, but you get the idea) of my XML
I edited the question after David Hanak's answer (thanks btw!). He helped with the
I have HTML code edited by FCKEditor stored in a database and would like
Here is an example of polymorphism from http://www.cplusplus.com/doc/tutorial/polymorphism.html (edited for readability): // abstract base
This question sounds so easy I can't believe I can't find information on it
Edited Question : I am working on a multithreaded JMS receiver and publisher code
Background This is the same background as my previous question , except the Outline

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.