My problem is that I want to create class witch will use stack library. But my compiler seems not to include library... Here is code :
hanoi.h
#ifndef HANOI
#define HANOI
#include <stack>
class hTower {
private :
stack<int> A; // Here is error
public :
hTower();
};
#endif
hanoi.cpp
#include <stack> #include <iostream> #include <cstdlib> #include "hanoi.h" using namespace std;
main.cpp
#include <iostream>
#include "hanoi.h"
using namespace std;
int main(int argc, char *argv[])
{
return 0;
}
Error :
"In file included from main.cpp,
ISO C++ forbids declaration of 'stack' with no type,
expected ';' before '<' token "
My question is, how to include stack library so that I can declare stack in my class? I've noticed the same problem with vector library...
Using Dev C++.
EDIT :
NVM, seems I had to put std:: before declaration. Problem solved.
Edited by notes, 16 November 2011 - 06:00 AM.
Solved myself


Sign In
Create Account


Back to top









