03 - Chapter OEjects CHAPTER ~ ~ GOALS To become familiar...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
Chapter OEjects CHAPTER GOALS ~ To become familiar with objects ~ To learn about the properties of several sample classes that were designed for this book ~ To be able to construct objects and supply initial values ~ To understand member functions and the dot notation ~ To be able to modify and query the state of an object through member functions ~ To write simple graphics programs containing points, lines, circles, and text (optional) You have learoed about the basic data items, or, as they are usually called, data types of C++: numbers and objects. It requires a certain degree of strings. While it is possible to write technical mastery to design new object interesting programs using only num- types, but it is quite easy to manipulate bers and strings, most useful programs object types that have been designed by need to manipulate data items that are others. Therefore, you will first learn more complex and more closely repre- how to use objects that were specifically sent entities in the real world. Exam- designed for use with this textbook. In ples of these data items are employee Chapter 6 you will learn how to define records or graphical shapes. these and other objects. Some of the The C++ language is ideally suited most interesting data structures that we for designing and manipulating such consider are from the realm of
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
CHAPTER 3 Objects graphics. In this chapter you will learn how to use objects that let you draw graphical shapes on the computer screen. To keep programming simple, we introduce only a few building blocks. You will find that the ability to draw simple graphics makes programming much more fun. However, the use of the graphics library is entirely optional. The remainder of this book does not depend on graphics. CHAPTER CONTENTS 3.1 Constructing Objects 80 3.5 Graphics Structures 92 Syntax 3.1: Object Construction 81 Productivity Hint 3.3: Think of Points as Objects, Syntax 3 2: Object Variable Definition 82 Not Pairs of Numbers 96 3.2 Using Objects Random Fact 3.2: Computer Graphics 96 Common Error 3.1: Trying to Call a Member 3.6 Choosing a Coordinate System 98 Function without a Variable 56 Productivity Hint 3.4: Choose a Convenient Productivity Hint 3.1: Keyboard Shortcuts for Coordinate System 101 Mouse Operations 56 3.7 Getting Input from the Graphics Window 102 3.3 Real-Life Objects 87 3.8 Comparing Visual and Numerical Productivity Hint 3.2: Using the Command Une Information 103 Effectively 89 Quality 'Tip 3.1: Calculate Sample Data Random Fact 3.1: Mainframes-When Dinosaurs Manually 106 Ruled the Earth Random Fact 3.3: Computer Networks and the 3.4 Displaying Graphical Shapes 91 Internet 107 Constructing Obj cts An object is a value that can be created, stored, and manipulated in a programming lan- guage. In that sense, the string "He110" is an object. You can create it simply by using the C++ string notation "He110". You can store it in a variable like this: string greeting = "Hello"; You can manipulate it, for example, by computing a substring: cout « greeting.substr(O, 4); This particular manipulation does not affect the object. After the substring is computed,
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 02/28/2008 for the course CSCI 455 taught by Professor Bono during the Spring '08 term at USC.

Page1 / 36

03 - Chapter OEjects CHAPTER ~ ~ GOALS To become familiar...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online