Jump to ContentJump to Main Navigation
Applied Computational Physics$
Users without a subscription are not able to see the full content.

Joseph F. Boudreau and Eric. S. Swanson

Print publication date: 2017

Print ISBN-13: 9780198708636

Published to Oxford Scholarship Online: February 2018

DOI: 10.1093/oso/9780198708636.001.0001

Show Summary Details
Page of

PRINTED FROM OXFORD SCHOLARSHIP ONLINE (oxford.universitypressscholarship.com). (c) Copyright Oxford University Press, 2020. All Rights Reserved. An individual user may print out a PDF of a single chapter of a monograph in OSO for personal use. date: 05 December 2020

How to write a class

How to write a class

(p.151) 6 How to write a class
Applied Computational Physics

Joseph F. Boudreau

Eric S. Swanson

Oxford University Press

While there is no such thing as a “typical” C++ class, several common syntactical constructs lend themselves to extremely widespread use and must be mastered by C++ programmers. To motivate the discussion of software design at the level of the C++ class, examples from computer science and optics are introduced. Important syntactical elements such as constructors, destructors, copy constructors, assignment operators, cast operators, and const qualifiers, together with function overloading, operator overloading, and dynamic memory allocation are discussed. These concepts, illustrated with examples from physics, are presented and explained. Further examples from optical and quantum mechanical problems are left to the exercises. This chapter and its exercises gives the reader sufficient information to begin developing his or her own classes and to experiment with class design through trial and error.

Keywords:   C++, class, constructor, destructor, cast, design, syntax, assignment operator, optics, quantum mechanics

Oxford Scholarship Online requires a subscription or purchase to access the full text of books within the service. Public users can however freely search the site and view the abstracts and keywords for each book and chapter.

Please, subscribe or login to access full text content.

If you think you should have access to this title, please contact your librarian.

To troubleshoot, please check our FAQs , and if you can't find the answer there, please contact us .