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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:29:02+00:00 2026-05-19T12:29:02+00:00

I had a few questions in a technical interview that I thought I knew,

  • 0

I had a few questions in a technical interview that I thought I knew, but wanted to double-check (they said I passed it, but I was unsure about these):

  1. A variable declared inside a Class Method… Can that be used outside of that method, like for instance in another method? (I said no)

  2. Can a variable declared inside a method be passed as a parameter to another method?
    (I said yes but I wasn’t sure)


This is for an entry-level C++ position and I’m used to C, so I wanted to double-check my understanding of C++/OO concepts.

  • 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-19T12:29:03+00:00Added an answer on May 19, 2026 at 12:29 pm
    1. A variable within a class method, that’s instantiated within that method and wholly contained within that method, can only be used within that method. Its lifetime is finite. Edit: to clarify, I’m not saying it can’t be passed to another function call within the function scope and I’m not talking about instantiating a member variable or static variable.

    2. Yes, you can pass it to another method if that method is called from within the method it exists. Why? Because its lifetime it tied to the parent method, not the one that is called from within the method.

    Let me illustrate:

    //aVar does not exist.
    int foo(){
       int aVar = 1; //it's been born
       cout << doSomething(aVar); // still alive
    
       return aVar; //still alive but a copy is being returned from the function.  Not aVar itself!
    } // it's dead, man
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've had a few questions about MEF recently, but here's the big one --
I just had a quick phone interview. The interviewer asked me a few questions
This is probably a very dumb question, but I had a few questions about
I read about Big-O Notation from here and had few questions on calculating the
I'm working on an image resize script for php, and had a few questions..
Here's a few questions I had on a quiz in a class and just
I have had a few problems getting this right, so I wanted to ask
I was looking at this code and had a few questions. I did some
I searched SO and saw a few questions posted on the topic, but I
If you've seen my last few questions you'd know by now that I've been

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.