 |
C++Talk.NET C++ language newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Will Oram Guest
|
Posted: Thu Oct 30, 2003 1:14 am Post subject: Char Error |
|
|
Xcode, OS X's toolkit, compiles this, but chokes if anything (here, a '(
' char) is inputted. Its goal is to take an input string character by
character and put it in a linked list.
The output and error:
-------
EVALUATE THIS MATH EXPRESSION (no spaces or letters, please):
(
ZeroLink: unknown symbol '__ZN5StackIcE4pushERKc'
233_PA2_part2 has exited with status 1.
-------
...and the code (assume all pointers begin initialised as NULL):
-------
int main () {
Stack<char> myStack;
bool isValid = TRUE;
char expression[CAPACITY];
char currentChar = ' ';
char previousChar = ' ';
cout << "EVALUATE THIS MATH EXPRESSION (no spaces or letters, please):
n";
cin >> expression;
for (int j = 0; currentChar != ' '; ++j) {
previousChar = currentChar;
currentChar = expression[j];
if(!evaluateChar(currentChar, previousChar, myStack))
isValid = FALSE;
} }
}
-------
...which eventually calls the push function through evaluateChar:
-------
template <class Item>
void Stack<Item>::push(const Item &entry) {
Node *newChar;
newChar = new Node;
Node *test;
test = new Node;
bottom_ptr = newChar;
newChar -> data = entry;
newChar -> next = NULL;
if(empty())
top_ptr = newChar;
for (test = top_ptr; test != NULL; test = test -> next)
cout << test -> data << endl;
}
-------
I think it has something to do with main; doing functionwide commenting
out shows that it runs fine if push but not main is commented out.
Thanks.
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|