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!

AnhtuanA
P: 3
Expand|Select|Wrap|Line Numbers
  1. #include <stack.h>
  2.  
  3.  
  4. stack <int> intStack;
  5.  
  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


Ganon11
Expert 2.5K+
P: 3,652
Try

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

AnhtuanA
P: 3
Try

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

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

#include <stack>

Goodluck!
Nov 8 '06 #4

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

#include <stack>

Goodluck!
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. }
  7.  
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

AnhtuanA
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.