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.

Totally Immersed: <strong>C++</strong> Classes and Object-Oriented Programm<strong>in</strong>g<br />

Workshop<br />

Sometimes it’s necessary to take a couple days off and let it all soak <strong>in</strong>.<br />

In fact, if I thought I could get by with it I’d make Day 5 a blank<br />

chapter called “A Day of Rest.” Take it a little at a time, and one of<br />

these days you’ll be just like Archimedes—you’ll be runn<strong>in</strong>g around<br />

your office or your house shout<strong>in</strong>g “Eureka!” because the light just<br />

came on <strong>in</strong> your nogg<strong>in</strong>. But keep track of your clothes, will you? The<br />

neighbors could be watch<strong>in</strong>g.<br />

The Workshop conta<strong>in</strong>s quiz questions to help you solidify your understand<strong>in</strong>g of the<br />

material covered and exercises to provide you with experience <strong>in</strong> us<strong>in</strong>g what you have learned.<br />

You can f<strong>in</strong>d answers to the quiz questions <strong>in</strong> Appendix A, “Answers to Quiz Questions.”<br />

Q&A<br />

Q How can I keep a class member function private to the outside world but<br />

allow derived classes to call it?<br />

A Make it protected. A protected function is not accessible to users of your class but<br />

is accessible to derived classes.<br />

Q What does data abstraction mean?<br />

A Data abstraction means hid<strong>in</strong>g the details of the class that the users of the class<br />

don’t need to see. A class might have dozens of data members and functions, but<br />

only a few that the user can see. Make visible (public) only the functions that a user<br />

needs to know about to use the class.<br />

Q What is an object?<br />

A Effectively speak<strong>in</strong>g, an object is any block of code that can be treated as a separate<br />

entity <strong>in</strong> your programs. An object <strong>in</strong> <strong>C++</strong> generally means a class. In <strong>C++</strong>Builder,<br />

that def<strong>in</strong>ition is expanded to <strong>in</strong>clude VCL components. OCX and ActiveX<br />

controls could also be considered objects.<br />

Q Can my class have more than one constructor?<br />

A Yes. Your class can have as many constructors as needed, provided that you follow<br />

the rules of function overload<strong>in</strong>g.<br />

129<br />

4

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

Saved successfully!

Ooh no, something went wrong!