Siêu thị PDFTải ngay đi em, trời tối mất

Thư viện tri thức trực tuyến

Kho tài liệu với 50,000+ tài liệu học thuật

© 2023 Siêu thị PDF - Kho tài liệu học thuật hàng đầu Việt Nam

C++ Programming for Games Module II phần 1 pps
MIỄN PHÍ
Số trang
30
Kích thước
542.7 KB
Định dạng
PDF
Lượt xem
971

C++ Programming for Games Module II phần 1 pps

Nội dung xem thử

Mô tả chi tiết

C++ Programming for

Game Developers

Module II

e-Institute Publishing, Inc.

©Copyright 2005 e-Institute, Inc. All rights reserved. No part of this book may be reproduced or

transmitted in any form or by any means, electronic or mechanical, including photocopying, recording,

or by any information storage or retrieval system without prior written permission from e-Institute Inc.,

except for the inclusion of brief quotations in a review.

Editor: Susan Nguyen

Cover Design: Adam Hoult

E-INSTITUTE PUBLISHING INC

www.gameinstitute.com

Frank Luna, C++ Programming for Games II

All brand names and product names mentioned in this book are trademarks or service marks of their

respective companies. Any omission or misuse of any kind of service marks or trademarks should not be

regarded as intent to infringe on the property of others. The publisher recognizes and respects all marks

used by companies, manufacturers, and developers as a means to distinguish their products.

E-INSTITUTE PUBLISHING titles are available for site license or bulk purchase by institutions, user

groups, corporations, etc. For additional information, please contact the Sales Department at

[email protected]

i

Table of Contents

MODULE II OVERVIEW........................................................................................................................................................1

CHAPTER 10: INTRODUCTION TO TEMPLATES ..........................................................................................................2

INTRODUCTION ........................................................................................................................................................................3

CHAPTER OBJECTIVES .............................................................................................................................................................3

10.1 CLASS TEMPLATES...........................................................................................................................................................4

10.1.1 Class Template Definition.......................................................................................................................................7

10.1.2 Class Template Implementation ..............................................................................................................................7

10.1.3 Class Template Instantiation...................................................................................................................................8

10.2 EXAMPLE: A TABLE TEMPLATE CLASS.............................................................................................................................9

10.2.1 Table Data...............................................................................................................................................................9

10.2.2 Class Interface.......................................................................................................................................................10

10.2.3 The destroy Method..........................................................................................................................................11

10.2.4 The resize Method ............................................................................................................................................11

10.2.5 The Overloaded Parenthesis Operator .................................................................................................................13

10.2.6 The Table Class.....................................................................................................................................................13

10.3 FUNCTION TEMPLATES ..................................................................................................................................................17

10.3.1 Example Program .................................................................................................................................................18

10.4 SUMMARY......................................................................................................................................................................21

10.5 EXERCISES .....................................................................................................................................................................21

10.5.1 Template Array Class............................................................................................................................................21

10.5.2 Template Bubble Sort Function.............................................................................................................................22

10.5.3 Table Driver ..........................................................................................................................................................22

CHAPTER 11: ERRORS AND EXCEPTION HANDLING...............................................................................................23

INTRODUCTION ......................................................................................................................................................................24

CHAPTER OBJECTIVES ...........................................................................................................................................................24

11.1 ERROR CODES................................................................................................................................................................24

11.2 EXCEPTION HANDLING BASICS......................................................................................................................................26

11.3 ASSERT ..........................................................................................................................................................................29

11.4 SUMMARY......................................................................................................................................................................31

11.5 EXERCISES .....................................................................................................................................................................31

11.5.1 Exception Handling...............................................................................................................................................31

CHAPTER 12: NUMBER SYSTEMS ...................................................................................................................................33

INTRODUCTION ......................................................................................................................................................................34

CHAPTER OBJECTIVES ...........................................................................................................................................................34

12.1 NUMBER SYSTEMS.........................................................................................................................................................34

12.1.1 The Windows Calculator.......................................................................................................................................35

12.2 THE BINARY NUMBER SYSTEM......................................................................................................................................37

12.2.1 Counting in Binary................................................................................................................................................37

12.2.2 Binary and Powers of 2.........................................................................................................................................38

12.2.3 Binary Arithmetic ..................................................................................................................................................39

Addition.......................................................................................................................................................................................... 39

Subtraction...................................................................................................................................................................................... 41

Multiplication ................................................................................................................................................................................. 43

12.2.4 Converting Binary to Decimal ..............................................................................................................................43

12.2.5 Converting Decimal to Binary ..............................................................................................................................44

12.3 THE HEXADECIMAL NUMBER SYSTEM...........................................................................................................................45

12.3.1 Counting in Hexadecimal......................................................................................................................................45

12.3.2 Hexadecimal Arithmetic........................................................................................................................................46

Addition.......................................................................................................................................................................................... 46

Tải ngay đi em, còn do dự, trời tối mất!