Example: air traffic controller

Programming and Graphics - klebcahubli.in

Programming and GraphicsIntroduction to C++ 1 3C. PozrikidisProgramming and GraphicsIntroduction to C++Constantine Pozrikidis Department of Mechanical and Aerospace Engineering (MAE) University of California, San Diego 9500 Gilman Drive La Jolla, CA 92093-0411 Cover illustration: The illustration on the front cover shows a twisted nanoring consisting of a warped hexagonal lattice of carbon atoms. Library of Congress Control Number: 2007921582 ISBN-10: 0-387-68992-3 e-ISBN-10: 0-387-68993-1 ISBN-13: 978-0-387-68992-0 e-ISBN-13: 978-0-387-68993-7 Printed on acid-free paper. 2007 Springer Science+Business Media, LLC All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis.

Preface vii it supports several dialects dependent on the chosen compiler. All compilers support the ANSI/ISO standard C++ functions discussed in this text.

Tags:

  Compiler

Information

Domain:

Source:

Link to this page:

Please notify us if you found a problem with this document:

Other abuse

Advertisement

Transcription of Programming and Graphics - klebcahubli.in

1 Programming and GraphicsIntroduction to C++ 1 3C. PozrikidisProgramming and GraphicsIntroduction to C++Constantine Pozrikidis Department of Mechanical and Aerospace Engineering (MAE) University of California, San Diego 9500 Gilman Drive La Jolla, CA 92093-0411 Cover illustration: The illustration on the front cover shows a twisted nanoring consisting of a warped hexagonal lattice of carbon atoms. Library of Congress Control Number: 2007921582 ISBN-10: 0-387-68992-3 e-ISBN-10: 0-387-68993-1 ISBN-13: 978-0-387-68992-0 e-ISBN-13: 978-0-387-68993-7 Printed on acid-free paper. 2007 Springer Science+Business Media, LLC All rights reserved. This work may not be translated or copied in whole or in part without the written permission of the publisher (Springer Science+Business Media, LLC, 233 Spring Street, New York, NY 10013, USA), except for brief excerpts in connection with reviews or scholarly analysis.

2 Use in connection with any form of information storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now known or hereafter developed is forbidden. The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to proprietary rights. 9 8 7 6 5 4 3 2 1 PrefaceThe C++ Programming language was introduced by Bjarne Stroustrup of theAT&T laboratories in 1985 as an extension of C, with additional features bor-rowed from the esoteric languageSimula. Since then, C++ has grown rapidlyin response to the practical need for a Programming language that is able toefficiently handle composite and diverse data types.

3 The language implementa-tion is pivoted on the ingenious concept ofobject oriented Programming (OOP).Today, C++ dominates the commercial market and is favored among systemprogrammers and application oriented programmingTo illustrate the advantages of an object oriented Programming languagecompared to a structured language such asMatlab,Fortran 77,orC,weassume that an international sports competition has been entered by runnersfrom many countries around the globe. The record of each runner consists ofseveral fields including name, country of origin, city of birth, date of birth, andbest performance a structured language, each one of these fields is normally registeredin a separate data vector.

4 In an OOP language, each runner becomes an objectdefined as a member of the class of runners, and each member is described bythe collection of these fields. This formalism allows us to record, recall, andmanipulate in any desired way the personal data of each runner using simplesymbolic operators. Sub-classes consisting, for example, of runners of a particu-lar nationality can be readily defined to facilitate more detailed OOP language allows us to introduce a data type of our choice viewedas an object in a defined class, and then use the class as a building block forfurther development. This flexibility essentially allows us to build a languagewithout building a compiler . In this sense, an OOP language is an and C++C++ is a generalization of C, but accomplishes much more than C, to theextent that it should be regarded, studied, and taught as a separate is neither necessary nor recommended to study C as a prerequisite of C++,though knowledge of C can be bookThis book is a brief and basic introduction to C++ for everyone andespecially for scientists and engineers.

5 The text offers a venue for effectivelyteaching and rapidly learning the language at the level of an undergraduatecourse in any discipline of the physical sciences and computer science and en-gineering. The discussion illustrates step-by-step the grammar, syntax, andmain features of the language, and explains the basic premise of OOP with anemphasis on scientific 1 reviews basic concepts of computer hardware software 2 and 3 outline the general features of C++ and the basicimplementation of the 4 discusses user-defined functions with an emphasis on Chapter 5 introduces pointers to memory addresses and demonstratestheir 6 explains the basic principles of object oriented Programming (OOP) and the implementation of 7 and 8 discuss Graphics and graphical user interface (GUI)

6 Programming based on the fabulousVoglelibrary for the X11 server, and onthe GLUT, GLUI, and GTK+ utility 9 demonstrates the use ofMatlabfunctions from C++ codefor numerics and to C++Many students, scientists, engineers, and other professionals are familiarwith the general concepts of computer Programming , are proficient in an easyprogramming language, such asMatlaborFortran 77, and would like tolearn C++. This book is ideally suited for this audience. Translation tablesdemonstrating the conversion ofMatlaborFortran 77code into C++ codeare given in an appendix. A side-by-side comparison illustrates the syntacticand functional differences between the three it simpleThe C++ language is pluralistic in two ways.

7 First, it allows differentcommands (tasks) to be stated (implemented) in alternative ways. Second,Prefaceviiit supports several dialects dependent on the chosen compiler . All compilerssupport the ANSI/ISO standard C++ functions discussed in this our discussion, structure and forms that make for a transparent andefficient, but not necessarily compact, Programming style are adopted. Codeobfuscation is avoided at all from the InternetThis text was written with a new learning model in mind: study a basictext or take a short course to get acquainted with a subject, and then use theInternet to master the subject. A wealth of up-to-date resources and tutorialsare available on the Internet on every imaginable this text to get acquainted with C++, and then use the Internetto master the Internet siteThis book is accompanied by a library of programs that can be freelydownloaded from the Internet site: information on C++ and links of interest are also C++ programmer without Unix experience is handicapped in manyways.

8 A number of Unix operating systems are freely available and can bereadily installed either by themselves or in a dual boot mode along with Win-dows on desktops and laptops Examples includeFedora Core,CentOs,andBSD. Appendix A summarizes the basic Unix for Windows usersThe software packagecygwinallows Windows users to work in a Unixenvironment and utilize Unix libraries and applications on top of the windowsoperating system. Effectively,cygwincreates a computer running Unix insideanother computer running Windows. To distinguish between the two, we referto the former as an environment. Matlabusers are familiar with the conceptof a computing its name from three components:1. gnu: standing for GNU s Not Unix.

9 This is a free, open-source oper-ating system consisting of a kernel, libraries, system utilities, compilers,viiiPrefaceand end-user applications. Its development was announced by RichardStallman in Cygnus: a genus of beautiful Windows: an operating system produced by the Microsoft can be freely downloaded and easily installed from theInternet The package contains a wealth of ap-plications and tools, including the X11 Graphics library and a C++ users are strongly advised to download and install the package as aprelude to studying this am grateful to Todd Porteous, Conrad Palmer, and Micheal Waltz forproviding hardware, software, and moral am grateful to anonymous reviewers and to my editor Valerie Schofieldwho immediately recognized the significance of this book and provided PozrikidisSan Diego, March 2007 Contents1 Computers and Thebinarysystem.

10 Binarysystemarithmetic .. Computer Floating-point The hexadecimal General Features of C++ The main Grammar and Datatypes .. Vectors,arrays,andcompositedatatypes .. Standardnamespace .. Compiling in Simplecodes ..443 Programming in C++ Vector and matrix Controlstructures .. Receiving from the keyboard and displayingon the Mathematical Readfromafileandwritetoafile .. Formatted input and Sample Bitwise Preprocessor define and User-Defined Functions in the main Static Function Functions in individual files and header Functions with scalar Functions with array Externalvariables .. Function Recursive Function Pointers to scalars and Sorting with the Command line Pointers to Pointerstofreememory.


Related search queries