C
cipher
Guest
hi guys,
i'm currently working on my CS degree and have been using Visual C++. I just got an ibook and am using Xcode to create my applications. My question is about using exceptions in programs via Xcode. I created an application that includes some throw exception code in it. Whenever i try to compile and build in Xcode, I get a few errors returned to me. But when I try to compile and build the same exact code in Visual C++ it works perfectly. I was hoping someone could steer me in the right direction. I'll post the header files i'm using and the errors returned to me in this thread:
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
p()' throws different exceptions
StackA.cpp:38: error: declaration of `void Stack
p(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
p() throw (StackException)'
StackA.h:12: error: than previous declaration `void Stack
p(StackItemType&) throw (StackException)'
StackA.h:10: error: than previous declaration `void Stack:ush(int) throw (StackException)'
Thks....
i'm currently working on my CS degree and have been using Visual C++. I just got an ibook and am using Xcode to create my applications. My question is about using exceptions in programs via Xcode. I created an application that includes some throw exception code in it. Whenever i try to compile and build in Xcode, I get a few errors returned to me. But when I try to compile and build the same exact code in Visual C++ it works perfectly. I was hoping someone could steer me in the right direction. I'll post the header files i'm using and the errors returned to me in this thread:
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: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
StackA.h:12: error: than previous declaration `void Stack
StackA.h:10: error: than previous declaration `void Stack:ush(int) throw (StackException)'
Thks....