hi guys,
question on X11...i created a stack class and am trying to use throw exception as part of the program. unfortunately, i am getting errors when i compile in X11. i used the same exact code in visual c++ and received no errors. i was hoping someone could steer me in the right direction. here is the code and errors that i am receiving when compiling:
StackException.h file
#include <exception>
#include <string>
using namespace std;
class StackException: public exception //is this inheritance??
{
public:
StackException(const string &message=""): exception(message.c_str())
{
}
};
StackA.h file
#include "StackException.h"
typedef int StackItemType;
const int MAX_STACK = 20;
class Stack
{
public:
Stack();
bool isEmpty() const;
void push(StackItemType newItem) throw(StackException);
void pop() throw(StackException);
void pop(StackItemType &stackTop) throw(StackException);
void getTop(StackItemType &stackTop) const throw(StackException);
private:
char items[MAX_STACK];
int top;
};
Errors when I compile cpp files:
exception:55: error: std::exception::exception()
exception:53: error: candidates are: std::exception::exception(const std::exception&)
StackA.cpp:51: error: declaration of `void Stack::getTop(StackItemType&) const' throws different exceptions
StackA.cpp:27: error: declaration of `void Stack:
op()' throws different exceptions
StackA.cpp:38: error: declaration of `void Stack:
op(StackItemType&)' throws different exceptions
StackA.cpp:14: error: declaration of `void Stack:
ush(int)' throws different exceptions
StackException.h:10: error: no matching function for call to `std::exception::exception(const char*)'
StackA.h:13: error: than previous declaration `void Stack::getTop(StackItemType&) const throw (StackException)'
StackA.h:11: error: than previous declaration `void Stack:
op() throw (StackException)'
StackA.h:12: error: than previous declaration `void Stack:
op(StackItemType&) throw (StackException)'
StackA.h:10: error: than previous declaration `void Stack:
ush(int) throw (StackException)'
Thks....
question on X11...i created a stack class and am trying to use throw exception as part of the program. unfortunately, i am getting errors when i compile in X11. i used the same exact code in visual c++ and received no errors. i was hoping someone could steer me in the right direction. here is the code and errors that i am receiving when compiling:
StackException.h file
#include <exception>
#include <string>
using namespace std;
class StackException: public exception //is this inheritance??
{
public:
StackException(const string &message=""): exception(message.c_str())
{
}
};
StackA.h file
#include "StackException.h"
typedef int StackItemType;
const int MAX_STACK = 20;
class Stack
{
public:
Stack();
bool isEmpty() const;
void push(StackItemType newItem) throw(StackException);
void pop() throw(StackException);
void pop(StackItemType &stackTop) throw(StackException);
void getTop(StackItemType &stackTop) const throw(StackException);
private:
char items[MAX_STACK];
int top;
};
Errors when I compile cpp files:
exception:55: error: std::exception::exception()
exception:53: error: candidates are: std::exception::exception(const std::exception&)
StackA.cpp:51: error: declaration of `void Stack::getTop(StackItemType&) const' throws different exceptions
StackA.cpp:27: error: declaration of `void Stack:

StackA.cpp:38: error: declaration of `void Stack:

StackA.cpp:14: error: declaration of `void Stack:

StackException.h:10: error: no matching function for call to `std::exception::exception(const char*)'
StackA.h:13: error: than previous declaration `void Stack::getTop(StackItemType&) const throw (StackException)'
StackA.h:11: error: than previous declaration `void Stack:

StackA.h:12: error: than previous declaration `void Stack:

StackA.h:10: error: than previous declaration `void Stack:

Thks....