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.

408 Day 11<br />

NOTE<br />

The code <strong>in</strong> this example gets the values for the Width and Height<br />

properties of the form, performs some calculations, and then sets Width<br />

and Height back to where they were when you started. In the end<br />

noth<strong>in</strong>g changes, but there is a good reason for assign<strong>in</strong>g values to the<br />

Width and Height properties at the end of the function.<br />

If you don’t actually do someth<strong>in</strong>g with the variables x and y, you<br />

wouldn’t be able to <strong>in</strong>spect them because the compiler will optimize<br />

them and they won’t be available to watch. Essentially, the compiler<br />

can look ahead, see that the variables are never used, and just more or<br />

less discard them. Putt<strong>in</strong>g the variables to use at the end of the function<br />

avoids hav<strong>in</strong>g them optimized away by the compiler.<br />

I’ve brought this up several times now, but I want to make sure you<br />

have a basic understand<strong>in</strong>g of how an optimiz<strong>in</strong>g compiler works.<br />

When you start debugg<strong>in</strong>g your applications, this knowledge will help<br />

avoid some frustration when you start gett<strong>in</strong>g those Variable ‘x’ has<br />

been optimized and is not available messages <strong>in</strong> the Watch List.<br />

The Debug Inspector<br />

NOTE<br />

Simply stated, the Debug Inspector allows you to view data objects such as classes and<br />

components (components are really just classes, anyway). You can also <strong>in</strong>spect simple data<br />

types such as <strong>in</strong>tegers, character arrays, and so on, but those are best viewed with the Watch<br />

List. The Debug Inspector is most useful <strong>in</strong> exam<strong>in</strong><strong>in</strong>g classes and structures.<br />

You can use the Debug Inspector only when program execution is<br />

paused under the debugger.<br />

To <strong>in</strong>spect an object, click on the object’s name <strong>in</strong> a source file and choose Inspect from the<br />

Code Editor speed menu (or press Alt+F5). You could also choose Run | Inspect from the<br />

ma<strong>in</strong> menu.

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

Saved successfully!

Ooh no, something went wrong!