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.

128 Day 4<br />

NOTE<br />

This will open the file <strong>in</strong> b<strong>in</strong>ary mode and move the file po<strong>in</strong>ter to the end of the file. Any<br />

new data will be written to the end of the file.<br />

B<strong>in</strong>ary files are treated differently than text files (see the b<strong>in</strong>ary specifier<br />

<strong>in</strong> Table 4.1). To read b<strong>in</strong>ary files, you will have to have an understand<strong>in</strong>g<br />

of the read(), write(), put(), and get() functions. We don’t<br />

have the time to go <strong>in</strong>to each of those functions at this po<strong>in</strong>t. If you<br />

need more <strong>in</strong>formation on b<strong>in</strong>ary file operations, you might want to<br />

get a good book on <strong>C++</strong> that covers file I/O <strong>in</strong> detail.<br />

Basic file I/O is pretty easy, really. But as I said earlier, if you need to do complicated file<br />

I/O, you are go<strong>in</strong>g to have to tie <strong>in</strong>to the onl<strong>in</strong>e help or get hold of a good book on file I/O<br />

<strong>in</strong> <strong>C++</strong> (aga<strong>in</strong>, <strong>Teach</strong> <strong>Yourself</strong> <strong>Borland</strong> <strong>C++</strong> 4.5 <strong>in</strong> 21 <strong>Days</strong>, Second Edition by Sams Publish<strong>in</strong>g<br />

is a good bet).<br />

Summary<br />

Today you have learned about classes <strong>in</strong> <strong>C++</strong>. A well-designed class is easy to use and saves<br />

many programm<strong>in</strong>g hours. I’d even go so far as to say that a well-designed class is a joy to<br />

use—especially when it’s of your own creation. Early <strong>in</strong> the chapter you learned about some<br />

of the features of functions that are specific to <strong>C++</strong>. You learned about function overload<strong>in</strong>g,<br />

virtual functions, <strong>in</strong>l<strong>in</strong>e functions, and default parameters <strong>in</strong> functions. All these are heavily<br />

used <strong>in</strong> design<strong>in</strong>g classes <strong>in</strong> <strong>C++</strong>. F<strong>in</strong>ally, the chapter f<strong>in</strong>ished up with an <strong>in</strong>troduction to basic<br />

file I/O operations.<br />

The lessons of these first four days are important to understand as you cont<strong>in</strong>ue through this<br />

book. If it doesn’t make complete sense to you, don’t despair. As we cont<strong>in</strong>ue through the<br />

follow<strong>in</strong>g days, you will see these concepts repeated and put to use <strong>in</strong> programs that have more<br />

practical application than the console apps we’ve been work<strong>in</strong>g with thus far.<br />

WARNING<br />

Learn<strong>in</strong>g <strong>C++</strong> can and will lead to bra<strong>in</strong> overload! It’s natural, and you<br />

shouldn’t worry about it. You might put down this book for the<br />

even<strong>in</strong>g, turn out the lights, and th<strong>in</strong>k, “I’ll never get it.” Trust me, you<br />

will.

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

Saved successfully!

Ooh no, something went wrong!