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.

Quiz<br />

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

1. How do you set a breakpo<strong>in</strong>t on a particular l<strong>in</strong>e of code?<br />

2. What is an <strong>in</strong>valid breakpo<strong>in</strong>t?<br />

3. How do you set a conditional breakpo<strong>in</strong>t?<br />

4. How can you change the properties of an item <strong>in</strong> the Watch List?<br />

5. What’s the quickest way to add a variable to the Watch List?<br />

6. What tool do you use to view the data members and methods of a class?<br />

7. How do you trace <strong>in</strong>to a function call when stepp<strong>in</strong>g with the debugger?<br />

8. How can you change the value of a variable at runtime?<br />

9. What is the difference between the TRACE and WARN macros?<br />

10. How do you view the output from the TRACE and WARN macros?<br />

Exercises<br />

1. Load the ScratchPad program that you created a few days ago. Place breakpo<strong>in</strong>ts <strong>in</strong><br />

the FileOpenClick() and FileSaveClick() functions. Run the program. When<br />

program execution pauses, <strong>in</strong>spect the OpenDialog and SaveDialog classes, respectively.<br />

2. Cont<strong>in</strong>u<strong>in</strong>g with exercise 1, step through the program when you stop at a<br />

breakpo<strong>in</strong>t and exam<strong>in</strong>e the program’s operation as you step through the functions.<br />

3. Load the DebugTst program you created earlier <strong>in</strong> this chapter. Place a breakpo<strong>in</strong>t<br />

<strong>in</strong> the WatchBtnClick() function. Add the s and x variables to the Watch List. Add<br />

each variable to the Watch List four times. Edit each of the watches and change the<br />

display options. Run the program and step through the function to see the effects<br />

<strong>in</strong> the Watch List.<br />

4. Add a conditional breakpo<strong>in</strong>t to the function <strong>in</strong> exercise 3. Place it on the l<strong>in</strong>e<br />

immediately after the l<strong>in</strong>e that reads <strong>in</strong>t x = Width. Make the condition x == 0<br />

and run the program. What happens?<br />

5. Cont<strong>in</strong>u<strong>in</strong>g with exercise 4, edit the breakpo<strong>in</strong>t and change the condition to<br />

x > 400. Run the program. Change the w<strong>in</strong>dow’s size and click the Watch Test<br />

button. Repeat this process several times, chang<strong>in</strong>g the w<strong>in</strong>dow’s size each time.<br />

What happens?<br />

6. Load any program and switch to the Code Editor. Place the cursor on any l<strong>in</strong>e of<br />

code and choose the Run to Cursor item from the Code Editor speed menu.<br />

Experiment with the program until the breakpo<strong>in</strong>t is hit.<br />

425<br />

11

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

Saved successfully!

Ooh no, something went wrong!