I have a problem in these 20 lines of code and can't find the answer...
I have a problem in these 20 lines of code and can't find the answer...
solution:
post the code.
Oops!
Just one second. Code in a second. It must have accidently deleted...
Oh, and btw, when you post the code, let us know what the problem is. If it's a compile-time message, then give us the error message, and the line number (and point out where that generally is in the code). If it's a runtime error, describe the problem in detail.
Code:#include “Cursor.h” template <class Object> Cursor<Object>: :Cursor( ) { header = NULL; cursorPosition = NULL; } template <class Object> bool Cursor<Object>: :isEmpty ( ) const { Return header = NULL; } template <class Object> void Cursor<Object>: :insert (const Object & x) { CNode<Object> *newItem; newItem = new CNode<Object>(x, NULL); if (isEmpty( ) ) header = newItem; else { newItem->next = cursorPosition->next; cursorPosition->next = newItem; } cursorPosition = newItem ; printText ( ) ; } template <class Object> void Cursor<Object>: : printText ( ) { CNode<Object> *p; If (isEmpty( ) ) { cout<<’|’; return; } for (p=header;p!=cursorPosition;p=p->next) cout<<p->element; cout<<cursorPosition->element; cout<<’|’; for (p=cursorPosition->next;p!=NULL;p=p->next) cout<<p->element; } template <class Object> void Cursor<Object>: :left ( ) { CNode<Object> *p; If (isEmpty ( ) ) { cout<<’\n|’; return: } For (p=header; p!=cursorPosition;p=p->next) cout<<p->element; cout<<p->element; cout<<’|’; //for (p=cursorPosition->next;p!=NULL;p=p->next) //cout<<p->element; }
I need to know how to move the cursor position left.
.
.
.
Last edited by Amanda2; 10-03-2007 at 06:53 PM. Reason: addition.
Google gotoxy() . That's the only solution I know but it's an awful one.
.
.
.
Need a real explanation...Thanks.
.
.
.
Why do I get the feeling this is supposed to be a simple console program, but you've gone out and grabbed the first bit of code from the net which mentions the words "cursor" and "left" without any regard to what it actually did.
Post some of YOUR code so we can hopefully establish the context in which you're trying to manipulate the cursor.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
In the mixture of a lot of off topic back and forth between me and Desolation, my opinion of the actual problem was deleted. ggz.