Index Cialdini Raobert Wywieranie wpływu na ludzi Teoria i pra (3) Bettelheim Bruno Cudowne i pożyteczne O znaczeniach i wartoÂściach baÂśni (8) R01 (5).TXT 108 2 Jordan Robert Kolo Czasu t 5 cz 1 Ognie Niebios 79001 1 George Orwell Folwark zwierzęcy (13) 14 (511) lex polonica 4 |
[ Pobierz całość w formacie PDF ] .Lines 9-29 declare the Rectangle class.There are public accessor methodsfor obtaining and setting the width and height of the rectangle, as well as for computingthe area and perimeter.Lines 32-43 contain the class function definitions that werenot declared inline.The function prototypes, for the non-class member functions, are on lines 47-50,and the program begins on line 52.The essence of this program is to generate a rectangle,and then to print out a menu offering five options: Draw the rectangle, determineits area, determine its perimeter, resize the rectangle, or quit.A flag is set on line 58, and when that flag is not set to TRUE the menuloop continues.The flag is only set to TRUE if the user picks Quit fromthe menu.Each of the other choices, with the exception of ChangeDimensions, callsout to a function.This makes the switch statement cleaner.ChangeDimensionscannot call out to a function because it must change the dimensions of the rectangle.If the rectangle were passed (by value) to a function such as DoChangeDimensions(),the dimensions would be changed on the local copy of the rectangle in DoChangeDimensions()and not on the rectangle in main().On Day 8, "Pointers," andDay 10, "Advanced Functions," you'll learn how to overcome this restriction,but for now the change is made in the main() function.Note how the use of an enumeration makes the switch statement much cleanerand easier to understand.Had the switch depended on the numeric choices(1-5) of the user, you would have to constantly refer to the description of the menuto see which pick was which.On line 63, the user's choice is checked to make sure it is in range.If not,an error message is printed and the menu is reprinted.Note that the switchstatement includes an "impossible" default condition.This is an aid indebugging.If the program is working, that statement can never be reached.Week in ReviewCongratulations! You've completed the first week! Now you can create and understandsophisticated C++ programs.Of course, there's much more to do, and next week startswith one of the most difficult concepts in C++: pointers.Don't give up now, you'reabout to delve deeply into the meaning and use of object-oriented programming, virtualfunctions, and many of the advanced features of this powerful language.Take a break, bask in the glory of your accomplishment, and then turn the pageto start Week 2 [ Pobierz całość w formacie PDF ] |
||||
Wszelkie Prawa Zastrzeżone! Kawa była słaba i bez smaku. Nie miała treści, a jedynie formę. Design by SZABLONY.maniak.pl. | |||||