New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

Start a Discussion

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Development and Darwin Discussion and questions about development for Mac OS X.

Question about exceptions in C++ via Xcode

Post Reply New Thread Subscribe

Thread Tools
Posts: n/a

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??

StackException(const string &message=""): exception(message.c_str())

StackA.h file
#include "StackException.h"
typedef int StackItemType;
const int MAX_STACK = 20;

class 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);

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 Stackp()' throws different exceptions
StackA.cpp:38: error: declaration of `void Stackp(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 Stackp() throw (StackException)'
StackA.h:12: error: than previous declaration `void Stackp(StackItemType&) throw (StackException)'
StackA.h:10: error: than previous declaration `void Stack:ush(int) throw (StackException)'

QUOTE Thanks
Posts: n/a

Im also getting bad compiling errors when trying to compile C++ written code in XCode.

for example even when I do a g++ compile in terminal, i get the same errors as in Xcode. But the errors seem to be incongruent with C++ programming style. Look at my code followed by the errors. Any suggestions would be monumental!!! I have a C++ programming class and if I can get the C++ compiler to work I would be in heaven.

int main () {
string word[]={"Arizona","walk","government","C++","beach");
int wordsize = sizeof(word)/sizeof(string), i;
for (int j=0;j<wordsize;j++)
cout<<word[j]<<" ";
cout << endln;
//now pass each word to numberVowels
for (i=0;i<wordsize;i++)
cout<<word[i]<<": ",,numberVowels(word[i])<<" vowels"<<endl;
return 0;


main.cpp: In function `int main()':
main.cpp:12: error: parse error before `)' token
main.cpp:13: error: `i' undeclared (first use this function)

the latter errors seem to be errors that wouldnt be flagged in a C++ compiler. Am I wrong?
QUOTE Thanks

rman's Avatar
Member Since: Dec 24, 2002
Location: Los Angeles, California
Posts: 12,584
rman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud ofrman has much to be proud of
Mac Specs: 2 x 3.0GHz Quad-Core, 6GB OS X 10.6.8 | 15in MacBook Pro 2.2GHz OS X 10.6.8 | 64GB iPad 2 WiFi

rman is offline
Here is what I see. First you defined the type of j efore using it, but not i. Second the following statement is unbalanced:

string word[]={"Arizona","walk","government","C++","beach");

If you count the number of brackets verses parentheses.

Life isn't about waiting for the storm to pass, It's about learning to dance in the rain!
QUOTE Thanks

Post Reply New Thread Subscribe

« Unix | Programming on the Mac »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Starter
Last Post
OS question PRinMD Switcher Hangout 2 02-17-2004 11:15 AM
XCode build hangs? robin OS X - Development and Darwin 3 01-12-2004 01:42 AM
Easiest Compiled Language in Xcode? Jetroza OS X - Development and Darwin 3 01-02-2004 02:42 AM
New Xcode plug-in helps developers reuse code Murlyn OS X - Development and Darwin 0 11-10-2003 12:16 PM
Xcode developer tools updated Murlyn OS X - Development and Darwin 0 11-04-2003 05:09 PM

All times are GMT -4. The time now is 01:43 PM.

Powered by vBulletin
Copyright ©2000 - 2015, Jelsoft Enterprises Ltd.

Welcome to

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!

(4 digit year)

Already a member?