Try to bear in mind, this is for a real beginner who hasn't learnt that much yet. I'm looking to create what can best be descrbied as an "HTML anchor" in the program. For example, at one point in the program, an anchor point is created, and then later on, the user is prompted if he/she wishes to return to that point, such as you would expect in a basic menu situation.
How might I go about this?
C++ programmers I need some help please?
Kenshin Himura is right here...
The goto/%26lt;label%26gt;: was defined in ANSI C. However, its usage has been attributed to several syntax errors which are hard to find and debug.
ANSI C/C++ has been designed to rid your programs of these statements. But, in some (rare) cases, they might be more useful.
To avoid contradicting myself, use them RARELY, if ever.
Reply:I'm not sure I understand completely what you are asking. Are you talking about something like a "Main" form, that the user can always return to? Or are you talking about the code itself, and returning to a specific line number in the code?
If you are talking about the former, all you need to do is create a MAIN form, and have all other forms spawn from it, and either pass a reference to the main form the child forms, or implement some kind of "controller" to mediate communication between the forms. Not sure if this is what you were asking - hope it helps.
Reply:Sounds like you mean a 'goto', 'label' situation.
You specify a label in the program code (a reference point), and then issue a goto command for that label name.
This is a very dangerous mecahnism not typically used in object oriented languages and will almost certainly backfire on you if your code is complex.
There are far safer and better mechanisms to use instead of goto. You should consider redesigning your program so that it doesn't require the use of explicit jumps. Consider a state machine, which would allow the operator to transfer between (and back to previous) code states.
Edit:
If you detailed your design goal better we might be able to provide a more robust solution.
salary survey
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment