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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

406 Day 11<br />

you want to view the details of the class. For view<strong>in</strong>g all the data<br />

members of a class, you should use the Debug Inspector, which I’ll<br />

discuss <strong>in</strong> a m<strong>in</strong>ute.<br />

Us<strong>in</strong>g the Watch List<br />

When a breakpo<strong>in</strong>t is hit, the Watch List will display the current value of any variables that<br />

have been added to the Watch List. If the Watch List is not currently open, you can choose<br />

View | Watches from the ma<strong>in</strong> menu to display it.<br />

Under certa<strong>in</strong> circumstances, a message will be displayed next to the variable rather than the<br />

variable’s value. If, for <strong>in</strong>stance, a variable is out of scope or not found, the Watch List displays<br />

Undef<strong>in</strong>ed symbol ‘x’ next to the variable name. If the program is not runn<strong>in</strong>g or if the<br />

program is not stopped at a breakpo<strong>in</strong>t, the Watch List will display [process not accessible]<br />

for all watch items. A disabled watch item will have next to it. Other messages<br />

may be displayed depend<strong>in</strong>g on the current state of the application or the current state of a<br />

particular variable.<br />

As I said yesterday, you may on occasion see Variable has been optimized and is not<br />

available <strong>in</strong> the Watch List. This is one of the m<strong>in</strong>or disadvantages to hav<strong>in</strong>g an optimiz<strong>in</strong>g<br />

compiler. If you need to <strong>in</strong>spect variables that are subject to optimization, either declare the<br />

variable with the volatile keyword or turn off the Register Variables option on the Compiler<br />

page of the Project Options dialog box. After debugg<strong>in</strong>g, remove the volatile modifier from<br />

the variable.<br />

TIP<br />

The Watch List can be used as a quickie decimal/hexadecimal converter.<br />

To convert a hex number to decimal, choose Run | Add Watch<br />

from the ma<strong>in</strong> menu. Type the hexadecimal number <strong>in</strong> the Expression<br />

field and click OK. Both the hexadecimal number and the decimal<br />

equivalent will be displayed <strong>in</strong> the Watch List. To convert a decimal<br />

number to hex, perform the same procedure, except click the Hexadecimal<br />

radio button to change the display type to hexadecimal. Because<br />

the Expression field will accept a mathematical expression, you can also<br />

use the Watch List as a hex calculator. You can even mix hexadecimal<br />

and decimal values <strong>in</strong> the same expression.

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

Saved successfully!

Ooh no, something went wrong!