12.12.2012 Views

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

Teach Yourself Borland C++ in 14 Days - portal

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

NOTE<br />

Us<strong>in</strong>g the Debugger<br />

is highlighted <strong>in</strong> red. To clear the breakpo<strong>in</strong>t, click on the stop sign icon and the breakpo<strong>in</strong>t<br />

is removed. You can also press F5 or choose Toggle Breakpo<strong>in</strong>t from the Code Editor speed<br />

menu to toggle a breakpo<strong>in</strong>t on or off.<br />

A breakpo<strong>in</strong>t can only be set on a l<strong>in</strong>e that generates actual code.<br />

Breakpo<strong>in</strong>ts are not valid if set on blank l<strong>in</strong>es, comment l<strong>in</strong>es, or<br />

declaration l<strong>in</strong>es. You are not prevented from sett<strong>in</strong>g a breakpo<strong>in</strong>t on<br />

these types of l<strong>in</strong>es, but the debugger will warn you about the fact that<br />

you have set a breakpo<strong>in</strong>t on a l<strong>in</strong>e that conta<strong>in</strong>s no code. The follow<strong>in</strong>g<br />

l<strong>in</strong>es will produce an <strong>in</strong>valid breakpo<strong>in</strong>t warn<strong>in</strong>g:<br />

// this is a comment followed by a blank l<strong>in</strong>e<br />

<strong>in</strong>t x; // a declaration<br />

Breakpo<strong>in</strong>ts can be set on return statements or on the clos<strong>in</strong>g brace of<br />

a function.<br />

If you set a breakpo<strong>in</strong>t on an <strong>in</strong>valid l<strong>in</strong>e, the debugger will warn you that the breakpo<strong>in</strong>t may<br />

not be valid, but it won’t do that until you attempt to run the program. Figure 11.1 shows<br />

the warn<strong>in</strong>g message that is displayed when the debugger detects an <strong>in</strong>valid breakpo<strong>in</strong>t.<br />

Figure 11.1.<br />

A warn<strong>in</strong>g message for<br />

an <strong>in</strong>valid breakpo<strong>in</strong>t.<br />

If you click the Yes button <strong>in</strong> the warn<strong>in</strong>g dialog box, the program will run and any <strong>in</strong>valid<br />

breakpo<strong>in</strong>ts will be ignored. If you click No, you will be taken back to the Code Editor, where<br />

you can clear the <strong>in</strong>valid breakpo<strong>in</strong>t. Any <strong>in</strong>valid breakpo<strong>in</strong>ts will be highlighted <strong>in</strong> green,<br />

and the stop sign icon <strong>in</strong> the gutter will be grayed out.<br />

When the program is run under the debugger, it behaves as it normally would—until a<br />

breakpo<strong>in</strong>t is hit, that is. When a breakpo<strong>in</strong>t is hit, the IDE is brought to the top, and the<br />

breakpo<strong>in</strong>t l<strong>in</strong>e is highlighted <strong>in</strong> the source code. If you are us<strong>in</strong>g the default colors, the l<strong>in</strong>e<br />

where the program has stopped is highlighted <strong>in</strong> red because red <strong>in</strong>dicates a l<strong>in</strong>e conta<strong>in</strong><strong>in</strong>g<br />

a breakpo<strong>in</strong>t.<br />

NEW TERM<br />

The execution po<strong>in</strong>t <strong>in</strong>dicates the l<strong>in</strong>e that will be executed next <strong>in</strong> your source code.<br />

397<br />

11

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!