By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,227 Members | 1,241 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,227 IT Pros & Developers. It's quick & easy.

Can't use container - stack, help me!

P: 3
Expand|Select|Wrap|Line Numbers
  1. #include <stack.h>
  4. stack <int> intStack;
  6. void main(){
  7. intStack.push(1);
  8. intStack.push(2);
  9. intStack.push(3);
  10. }
When I compile this code by Turbo C++, the error is "can't include stack.h"
How can I use this container?
Nov 4 '06 #1
Share this Question
Share on Google+
5 Replies

Expert 2.5K+
P: 3,652

Expand|Select|Wrap|Line Numbers
  1. #include "stack.h"
Nov 4 '06 #2

P: 3

Expand|Select|Wrap|Line Numbers
  1. #include "stack.h"
No effect (T_T)
Nov 8 '06 #3

P: 40
I'm fairly new to C++, but you may try:

#include <stack>

Nov 8 '06 #4

Expert Mod 2.5K+
P: 4,677
I'm fairly new to C++, but you may try:

#include <stack>

In C++, any declaration other than '#include <stack>' will have an error that says it is a deprecated library. Either of the other two will probably work in C.

I believe your problem is that you have no 'main' statement. You don't even declare a stack, you just start pushing values on it.

Try initializing a stack in a main statement

Expand|Select|Wrap|Line Numbers
  1. #include <stack>
  2. using namespace std;
  3. int main() {
  4.    Stack intStack;
  5.    return 0;
  6. }
Probably not exactly like that - they had $15 table toppers tonight, but if you google '#include <stack>' I'm sure you can figure it out.
Nov 8 '06 #5

P: 3
My teacher said that Turbo C++ don't support this style of include.
#include <stack> just can be used in VC++
Nov 12 '06 #6

Post your reply

Sign in to post your reply or Sign up for a free account.