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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:17:14+00:00 2026-05-27T11:17:14+00:00

As mentioned in this tutorial: http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/ In computer programming, a stack is a container

  • 0

As mentioned in this tutorial:
http://www.learncpp.com/cpp-tutorial/79-the-stack-and-the-heap/

In computer programming, a stack is a container that holds other
variables (much like an array). However, whereas an array lets you
access and modify elements in any order you wish, a stack is more
limited. The operations that can be performed on a stack are identical
to the ones above:

1) Look at the top item on the stack (usually done via a function
called top()) 2) Take the top item off of the stack (done via a
function called pop()) 3) Put a new item on top of the stack (done via
a function called push())

But if I defined two variables in C++ I do not have to use them in the same order of definition:

Example:

int main() {
 int a;
 int b;

 b = 5;
 a = 6;
}

Is there a problem on this code? I can use them in any order I like!! I do not have to use the a first then the b.

Am I misunderstanding something? What is it?

  • 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-27T11:17:15+00:00Added an answer on May 27, 2026 at 11:17 am

    You are confusing two different kinds of stacks.

    One stack, is where some of the memory for your application is allocated. This would be part of a discussion about the stack and heap and where your memory is allocated.

    The other kind of stack is a data structure that conforms to a LIFO style of access. This could be implemented using a std::vector or other forms of data structures.

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

Sidebar

Related Questions

At the end of the artile here: http://www.learncpp.com/cpp-tutorial/45-enumerated-types/ It mentions the following sentence: Finally,
At the end of the article here: http://www.learncpp.com/cpp-tutorial/45-enumerated-types/ , it mentions the following: Finally,
I am a new facebook application deverloper. I followed this tutorial: http://www.adobe.com/devnet/facebook/articles/video_facebook_quick_start.html but I
I have been writting a keyword search script based on this tutorial: http://www.hackosis.com/2007/11/06/howto-simple-search-engine-with-php-and-mysql/ Like
i was beggining to follow a tutorial on elementtree in this site http://www.bigfatalien.com/?p=223 so
I'm following a tutorial on Zend Framework here (http://www.ibm.com/developerworks/opensource/tutorials/os-php-zend2/section2.html). I barely got started, but
I'm following this tutorial on CodeIgniter: http://ie.mirror.twsweb-int.com/codeigniter/user_guide/tutorial/index.html 4th page of tutorial: http://ie.mirror.twsweb-int.com/codeigniter/user_guide/tutorial/create_news_items.html In the
I'm using this tutorial: http://android-developers.blogspot.com/2011/04/customizing-action-bar.html I set a drop down list theme like this
5 star rating script I have is made based on this tutorial http://php.about.com/od/finishedphp1/ss/rating_script.htm I
I just saw this mentioned in Stack Overflow question Best WYSIWYG CSS editor and

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.