Computer Science 306 Study Guide

Similar documents
Short Notes of CS201

CS201 - Introduction to Programming Glossary By

C++ (Non for C Programmer) (BT307) 40 Hours

Absolute C++ Walter Savitch

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p.

Practical C++ Programming

The Foundation of C++: The C Subset An Overview of C p. 3 The Origins and History of C p. 4 C Is a Middle-Level Language p. 5 C Is a Structured

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

C++ Coding Standards. 101 Rules, Guidelines, and Best Practices. Herb Sutter Andrei Alexandrescu. Boston. 'Y.'YAddison-Wesley

Cpt S 122 Data Structures. Introduction to C++ Part II

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe

CERTIFICATE IN WEB PROGRAMMING

Instantiation of Template class

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things.

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites:

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity.

QUIZ. What are 3 differences between C and C++ const variables?

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

C++ for System Developers with Design Pattern

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

QUIZ. What is wrong with this code that uses default arguments?

QUIZ. How could we disable the automatic creation of copyconstructors

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p.

CGS 2405 Advanced Programming with C++ Course Justification

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object

QUIZ. How could we disable the automatic creation of copyconstructors

CS304 Object Oriented Programming Final Term

Interview Questions of C++

Introduction to C++ Systems Programming

B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET

Problem Solving with C++

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Ch. 3: The C in C++ - Continued -

Lecture Notes on Programming Languages

III. Classes (Chap. 3)

G52CPP C++ Programming Lecture 9

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS

Get Unique study materials from


UEE1302 (1102) F10: Introduction to Computers and Programming

Object-Oriented Design (OOD) and C++

Introduction to Computers and C++ Programming p. 1 Computer Systems p. 2 Hardware p. 2 Software p. 7 High-Level Languages p. 8 Compilers p.

Review of the C Programming Language

Review of the C Programming Language for Principles of Operating Systems

STRUCTURING OF PROGRAM

KLiC C++ Programming. (KLiC Certificate in C++ Programming)

Variables. Data Types.

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value

AN OVERVIEW OF C++ 1

2. COURSE DESIGNATION: 3. COURSE DESCRIPTIONS:

VALLIAMMAI ENGINEERING COLLEGE

What are the characteristics of Object Oriented programming language?

Chapter 15 - C++ As A "Better C"

Fast Introduction to Object Oriented Programming and C++

Tokens, Expressions and Control Structures

September 10,

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

Object Oriented Programming with c++ Question Bank

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a.

QUIZ. Source:

Writing an ANSI C Program Getting Ready to Program A First Program Variables, Expressions, and Assignments Initialization The Use of #define and

CE221 Programming in C++ Part 1 Introduction

Object-Oriented Programming

ECE 3574: Dynamic Polymorphism using Inheritance

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

2 ADT Programming User-defined abstract data types

CS 376b Computer Vision

CS3157: Advanced Programming. Outline

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed?

dewhurst_index.qxd 10/16/02 1:54 PM Page 309 Index

C++ Important Questions with Answers

Compulsory course in Computer Science

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 12: Classes and Data Abstraction

Table of Contents Preface Bare Necessities... 17

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions.

IS 0020 Program Design and Software Tools

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

QUIZ How do we implement run-time constants and. compile-time constants inside classes?

Ch02. True/False Indicate whether the statement is true or false.

Ch. 12: Operator Overloading

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018)

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab.

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS

Object Oriented Programming

Introduction to Programming Using Java (98-388)

Data Abstraction. Hwansoo Han

Object-Oriented Programming

Introduction to Programming

A A B U n i v e r s i t y

1: Introduction to Object (1)

Lecture 7. Log into Linux New documents posted to course webpage

CS201 Some Important Definitions

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak

COMP322 - Introduction to C++ Lecture 02 - Basics of C++

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17

Transcription:

Computer Science 306 Study Guide C++ for Programmers Computer Science 306 Study Guide (Print Version) Copyright and Credits - Unit 0 - Introduction to C++ for Programmers Section 1 - The programming environment Section 2 - Obtaining and installing a C++ compiler Section 3 - Coding style Section 4 - Programming guidelines Unit 1 - Introduction to Objects Section 1 - The progress of abstraction Section 2 - An object has an interface Section 3 - The hidden implementation Section 4 - Reusing the implementation Section 5 - Inheritance: reusing the interface Section 6 - Interchangeable objects with polymorphism Section 7 - Creating and destroying objects Section 8 - Exception handling: dealing with errors Section 9 - Analysis and design Section 10 - Extreme programming Section 11 - Why C++ succeeds Section 12 - Strategies for transition Unit 2 - Making & Using Objects Section 1 - The process of language translation Section 2 - Tools for separate compilation Section 3 - Your first C++ program Section 4 - More about iostreams Section 5 - Introducing strings Section 6 - Reading and writing files Section 7 - Introducing vector Unit 3 - The C in C++ Section 1 - Creating functions Section 2 - Controlling execution Section 3 - Introduction to operators Section 4 - Introduction to data types Section 5 - Scoping Section 6 - Specifying storage allocation Section 7 - Operators and their use Section 8 - Composite type creation Section 9 - Debugging hints Section 10 - Function addresses Section 11 - Make: managing separate compilation Unit 4 - Data Abstraction Section 1 - A tiny C-like library Section 2 - What's wrong? Section 3 - The basic object Section 4 - What's an object? Computer Science 306 Study Guide 1

Section 5 - Abstract data typing Section 6 - Object details Section 7 - Header file etiquette Section 8 - Nested structures Unit 5 - Hiding the Implementation Section 1 - Setting limits Section 2 - C++ access control Section 3 - Friends Section 4 - Object layout Section 5 - The class Section 6 - Handle classes Unit 6 - Initialization & Cleanup Section 1 - Guaranteed initialization with the constructor Section 2 - Guaranteed cleanup with the destructor Section 3 - Elimination of the definition block Section 4 - Stash with constructors and destructors Section 5 - Stack with constructors & destructors Section 6 - Aggregate initialization Section 7 - Default constructors Unit 7 - Function Overloading & Default Arguments Section 1 - More name decoration Section 2 - Overloading example Section 3 - unions Section 4 - Default arguments Section 5 - Choosing overloading vs. default arguments Unit 8 - Constants Section 1 - Value substitution Section 2 - Pointers Section 3 - Function arguments & return values Section 4 - Classes Section 5 - volatile Unit 9 - Inline Functions Section 1 - Preprocessor pitfalls Section 2 - Inline functions Section 3 - Stash & Stack with inlines Section 4 - Inlines & the compiler Section 5 - Reducing clutter Section 6 - More preprocessor features Section 7 - Improved error checking Unit 10 - Name Control Section 1 - Static elements from C Section 2 - Namespaces Section 3 - Static members in C++ Section 4 - Static initialization dependency Section 5 - Alternate linkage specifications Unit 11 - References & the Copy-Constructor Section 1 - Pointers in C++ Section 2 - References in C++ Section 3 - The copy-constructor Section 4 - Pointers to members C++ for Programmers 2

Unit 12 - Operator Overloading Section 1 - Warning & reassurance Section 2 - Syntax Section 3 - Overloadable operators Section 4 - Non-member operators Section 5 - Overloading assignment Section 6 - Automatic type conversion Unit 13 - Dynamic Object Creation Section 1 - Object creation Section 2 - Early examples redesigned Section 3 - new & delete for arrays Section 4 - Running out of storage Section 5 - Overloading new & delete Unit 14 - Inheritance & Composition Section 1 - Composition syntax Section 2 - Inheritance syntax Section 3 - The constructor initializer list Section 4 - Combining composition & inheritance Section 5 - Order of constructor & destructor calls Section 6 - Name hiding Section 7 - Functions that don't automatically inherit Section 8 - Choosing composition vs. inheritance Section 9 - protected Section 10 - Operator overloading & inheritance Section 11 - Multiple inheritance Section 12 - Incremental development Section 13 - Upcasting Unit 15 - Polymorphism & Virtual Functions Section 1 - Evolution of C++ programmers Section 2 - Upcasting Section 3 - virtual functions Section 4 - How C++ implements late binding Section 5 - Why virtual functions? Section 6 - Abstract base classes and pure virtual functions Section 7 - Inheritance and the VTABLE Section 8 - Overloading & overriding Section 9 - virtual functions & constructors Section 10 - Destructors and virtual destructors Section 11 - Operator overloading Section 12 - Downcasting Unit 16 - Introduction to Templates Section 1 - Containers Section 2 - Overview of templates Section 3 - Template syntax Section 4 - Stack and Stash as templates Section 5 - Turning ownership on and off Section 6 - Holding objects by value Section 7 - Introducing iterators Section 8 - Why iterators? C++ for Programmers 3

Copyright and Credits: Back to top Copyright Correspondence can be directed to Copyright Office Athabasca University 1 University Drive Athabasca AB T9S 3A3 Website: http://emd.athabascau.ca/service_copyright.htm Email: copyright@athabascau.ca When linking to a specific page on this site (deep-linking), please also link to the main site at: http://www.athabascau.ca The course materials posted to this site are the exclusive property of Athabasca University. Users may load this content into their client browser programs for temporary individual viewing in the normal process of web use. Otherwise, no material contained in these files may be downloaded, copied, adapted, printed, transferred, reproduced, or distributed by any means without the written consent of the copyright holder. In providing hypertext links to students, Athabasca University has not authorized any use of these materials that, if undertaken without permission of the copyright owners or their assignees, may constitute infringement of copyright. Permission for use of materials can only be granted by copyright owners or their assignees. Students registered in Athabasca University courses are expected to use sound judgment and discretion in visiting websites for research purposes associated with their coursework. Athabasca University will not be held responsible for the continuing availability of recommended sites, the content of sites found, or the consequences of visiting those sites. Every effort has been taken to ensure that these materials comply with the requirements of copyright clearances and appropriate credits. Athabasca University will attempt to incorporate in future reproductions any corrections that are communicated to it. The inclusion of any material in this publication is strictly in accord with the consents obtained and Athabasca University does not authorize or license any further reproduction or use without the consent of the copyright holder. Course Team Course Author and Coordinator: Richard Huntrods Copyright and Credits: 4

Course development assistance provided by the Educational Media Development Department of Athabasca University Athabasca University 2008 All rights reserved 5

Unit 0: Introduction to C++ for Programmers Back to top Before you begin this course, you will require a proper programming environment and a C++ compiler. Section 1 Section 2 Section 3 Section 4 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises Use the course conference to share your experiences with other students under the Unit 0 topic. Unit 0: Introduction to C++ for Programmers 6

Unit 0 - Section 1 : The programming environment Back to Unit 0 Having the proper programming environment on your computer is essential to the successful completion of this course. list the essential components of a good programming environment; list the steps to install the essential components of a good programming environment on your computer; list two key contacts should you have difficulties installing or using the GNU C++ compiler. Log on to the course Moodle page read all topics under the "News forum" link. List the essential components of a good programming environment. List the steps to install the essential components of a good programming environment on your computer. List two key contacts should you have difficulties installing or using the GNU C++ compiler. Obtain and install the tools required to create a proper programming environment on your computer. Exercises 7

Unit 0 - Section 2 : Obtaining and installing a C++ compiler Back to Unit 0 A good C++ compiler is essential to the successful completion of this course. locate the GNU C++ compiler for your computer; list the steps to install the GNU C++ compiler on your computer; list two key contacts should you have difficulties installing or using the GNU C++ compiler. Log on to the course Moodle page read all topics under the "News forum" link. List the location (URL) of the GNU C++ compiler that is appropriate for your computer. List the steps to install the GNU C++ compiler for your computer. List two key contacts should you have difficulties installing or using the GNU C++ compiler. Obtain and install the appropriate GNU C++ compiler for your computer. 8

Unit 0 - Section 3 : Coding style Back to Unit 0 Refer to the commentary in Appendix A: Coding Style, in Eckel, B. (2000). Thinking in C++: Vol. 1. Introduction to C++ (2nd ed.). Upper Saddle River, NJ: Prentice Hall (hereafter referred to as 'the textbook'). describe the coding style used in the textbook, and state where the style originated; list the standard file names for C++ source files; define the standard begin and end comment tags; describe the standard uses of parentheses, braces, and indentation; describe the common style for identifier names; list the common order of header inclusion; describe the term include guards for header files; describe the common use of namespaces; describe the common use of require() and assure(). Read Appendix A: Coding Style in the textbook Describe the coding style used in the textbook, and state where the style originated. List the standard file names for C++ source files. Define the standard begin and end comment tags. Describe the standard uses of parentheses, braces, and indentation. Describe the common style for identifier names. List the common order of header inclusion. Describe the term include guards for header files. Describe the common use of namespaces. Describe the common use of require() and assure(). 9

Unit 0 - Section 4 : Programming guidelines Back to Unit 0 Refer to the commentary in Appendix B: Programming Guidelines in the textbook. discuss the 73 programming guidelines from Appendix B. Read Appendix B: Programming Guidelines in the textbook. After reading through the programming guidelines, pick three guidelines that you think will be easy to implement in your own programming. Create a conference posting under the topic Unit 0, and write a paragraph explaining your choices and why you chose them. Compare your answers with others in the course. After reading through the programming guidelines, pick three guidelines that you think will be difficult to implement in your own programming. Create a conference posting under the topic for Unit 0, and write a paragraph explaining your choices and why you chose them. Compare your answers with others in the course. 10

Unit 1: Introduction to Objects Back to top -- Object-oriented programming (OOP) and the software crisis -- The basic features of object-oriented programming -- Introduction to analysis and design -- Benefits of C++ -- Suggestions for programming in C++ Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Section 8 Section 9 Section 10 Section 11 Section 12 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. 11

Activities In this unit, you have been presented with several objective exercises. Share your solutions to these exercises with students in the course conference under the Unit 1 topic. Activities 12

Unit 1 - Section 1 : The progress of abstraction Back to Unit 1 Abstractions are involved in the development and use of programming languages. discuss abstractions and their place in programming languages; list the 5 characteristics of object-oriented programming. List the 5 characteristics of object-oriented programming, as presented by Allan Kay. What programming language did Allan Kay use when creating his 5 characteristics of object-oriented programming? Unit 1 - Section 1 : The progress of abstraction 13

Unit 1 - Section 2 : An object has an interface Back to Unit 1 Objects have characteristics and behaviours known as the interface. discuss the origin of the keyword class, and its relationship to the object; define the keyword interface, and discuss its relationship to the object and the keyword class. What is a class? What is a type, and how does it relate to the class? What is an interface? What is the relationship between interface, type, class, and object? 14

Unit 1 - Section 3 : The hidden implementation Back to Unit 1 The relationship between class creators, client programmers, and the hidden implementation. define class creators and client programmers based on the readings; discuss the relationship between class creators and client programmers; define hidden implementation as it relates to class creators and client programmers. What is a class creator? What is a class programmer? Describe the relationship between class creator and class programmer. Define hidden implementation. Describe the relationship between hidden implementation and class creator, and the relationship between hidden implementation and class programmer. 15

Unit 1 - Section 4 : Reusing the implementation Back to Unit 1 The ability to reuse the implementation is explored. define reuse in terms of OOP and the implementation; define two key terms in OOP, composition and aggregation; draw a rudimentary UML diagram showing composition or aggregation. Why is reusability not easy to achieve? Define the phrase "creating a member object" in your own words. List two key terms of OOP presented in the readings. What are some of the reasons for the flexibility of composition? Do the terms composition and aggregation mean the same thing? Which of the following are examples of composition. Car --> Tire Cat --> Dog Engine --> Spark Plug Coat --> Pocket Using the 'Car and Engine' example from the textbook, draw three UML diagrams to illustrate composition or aggregation. Discuss your UML diagrams with your classmates in the conference. 16

Unit 1 - Section 5 : Inheritance: reusing the interface Back to Unit 1 Inheritance is the ability to take a class, clone it, and then add to and/or modify the clone. define the terms inheritance, base class, parent class, super class, derived class, inherited class, sub-class, and child class; describe the relationship between two classes that exhibit inheritance; define the keyword private; create examples of classes that demonstrate inheritance; discuss "is-a" and "like-a" inheritance relationships; create examples of classes using "is-a" and "like-a" inheritance relationships. Compare and contrast the definitions of the adjectives base, parent, and super when used to describe a class. Compare and contrast the definitions of the adjectives inherited, sub, and child when used to describe a class. Do the terms base, parent, and super mean the same thing when describing a class? Do the terms inherited, sub, and child mean the same thing when describing a class? Discuss the sentence: "When you inherit from an existing type, you create a new type." What is the primary difference between "is-a" and "like-a" inheritance relationships? Using the examples from this section of the textbook, create a UML diagram to show how you would add a new child class (Octagon) to the Shape inheritance structure. Discuss your UML diagram with your classmates in the conference. 17

Using the examples from this section of the textbook, create UML diagrams for the following inheritance systems. Discuss your UML diagrams with your classmates in the conference. Solar System, Mercury, Venus, Earth, Mars Sports Car, Station Wagon, Sedan, Automobile Create a UML diagram for an inheritance system that shows an "is-a" relationship. Discuss your example in the conference. Create a UML diagram for an inheritance system that shows a "like-a" relationship. Discuss your example in the conference. 18

Unit 1 - Section 6 : Interchangeable objects with polymorphism Back to Unit 1 Polymorphism. discuss polymorphism and its role in OOP; define the terms used to describe polymorphism, such as early binding, late binding, virtual, and upcasting. Define early binding. Define late binding. What is the primary difference between early and late binding? How does the C++ language support early binding? What is the purpose of the keyword virtual? Define the term upcasting. Unit 1 - Section 6 : Interchangeable objects with polymorphism 19

Unit 1 - Section 7 : Creating and destroying objects Back to Unit 1 The mechanism for creating objects when required, and removing objects once they are no longer needed, is an important part of OOP. describe how objects in C++ are created and destroyed; define terms such as heap and delete; describe the lifetime of an object, and the role of the garbage collector. How are objects created? What is the static storage area? What is the dynamic storage area, and how is it related to the heap? What is the purpose of the delete keyword? What is the role of the garbage collector? 20

Unit 1 - Section 8 : Exception handling: dealing with errors Back to Unit 1 Error handling is an important issue in programming. In OOP, the exception is a key aspect of error handling. define exception handling, and the role of the exception handler; define the terms throw and catch. Define the role of an exception handler in dealing with errors. Define the terms throw and catch, as they relate to exception handling. 21

Unit 1 - Section 9 : Analysis and design Back to Unit 1 OOP provides a new way of thinking about the design of a program. Analysis and design are essential elements when planning to develop software. list the five phases of design; list the five stages of object design; discuss the benefits of planning an OOP project. List the five phases of design. What is the role of the mission statement in the overall project plan? List the five stages of object design. What is the mission statement? What phase of the design incorporates the mission statement? List five key questions that should be discussed in phase 1. What are the three attributes of a class that should be developed in phase 2? Discuss the benefits of planning and design, versus coding without a definite plan. 22

Unit 1 - Section 10 : Extreme programming Back to Unit 1 Extreme Programming (XP) is a radical new approach to OOP. list the two key attributes of Extreme Programming (XP); discuss the benefits offered by XP. List the two key attributes of XP. Discuss the pros and cons of writing tests first. Discuss the pros and cons of pair programming. 23

Unit 1 - Section 11 : Why C++ succeeds Back to Unit 1 C++ is an OOP language that solves many of the problems facing developers in today's world. list the eight major benefits of C++. List the eight major benefits of C++. 24

Unit 1 - Section 12 : Strategies for transition Back to Unit 1 Tips and techniques for moving to OOP using C++. list the five guidelines to consider when making the transition to C++; list the three common management obstacles to using C++. List the five guidelines to consider when making the transition to C++. List the three common management obstacles to using C++. 25

Unit 2: Making & Using Objects Back to top -- Introduction to C++ syntax and program construction concepts. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of the Chapter 2 in the textbook. For the even numbered problems, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 2 topic. 26

Unit 2 - Section 1 : The process of language translation Back to Unit 2 All computer languages are translated from something that humans can understand to something that the machine can understand. describe the compilation process in C++. What is the difference between an interpreter and a compiler? List the steps in the compilation process. Exercises 27

Unit 2 - Section 2 : Tools for separate compilation Back to Unit 2 Separate compilation is important to the creation and support of large projects. use the linker to access external libraries in your programs; list the differences between declaration and definition; describe the linking process in C++; list the steps to using a library in a C++ program. List at least 3 differences between declaration and definition of variables. Give an example of the function declaration syntax. Give an example of a function definition. What is the purpose of the extern keyword in C++? What is the standard file extension for a C++ header file? Give an example of how to include a C++ header file. Describe the difference between using double quotes and angle brackets when writing a header include statement. List the three steps required to use a library in your C++ program 28

Unit 2 - Section 3 : Your first C++ program Back to Unit 2 Creating and compiling your first program in a new computer language is an important milestone in programming. code, compile, and test your first C++ program. Write an include statement to use the iostream header file. What is the purpose of the namespace command? List three things that make up the fundamentals of program structure. What system command from Unit 0 is used to invoke the C++ compiler on the "Hello World" program? How does the command differ from the one shown in the textbook? Use the Crimson Editor (see Unit 0) to code the example program, "Hello World". Use the C++ command line compiler to compile and link your program. Test your program to ensure the output is as expected. 29

Unit 2 - Section 4 : More about iostreams Back to Unit 2 Some of the rudimentary attributes of iostreams are introduced. write simple programs that are able to read character input from the keyboard. Define concatenation. What is the name of the iostream used for keyboard input in C++? Code, compile, and test the examples provided in this section in the textbook. 30

Unit 2 - Section 5 : Introducing strings Back to Unit 2 Strings are a C++ construct that provide significant benefits to the programmer wanting to deal with textual material in a program. write simple programs that make use of strings. In your own words, describe what is happening in the program "HelloStrings". 31

Unit 2 - Section 6 : Reading and writing files Back to Unit 2 C++ offers the ability to read from and write to files using the iostream with much less complexity than programming languages such as C. write simple programs that can read from and write to files. What header file is required to read and write files? What header file is implicitly included when you use the above header file? What is the name of the input stream? What is the name of the output stream? Which function call reads a line from the file? In your own words, describe what is happening in the example program "FillString" in the textbook. 32

Unit 2 - Section 7 : Introducing vector Back to Unit 2 Vectors are a container that can hold a large number of objects in a convenient form. write simple programs that employ vectors. Define the word template as used in the description of a vector class. List three ways in which a vector is a container. In your own words, describe what is happening in the example program "FillVector" in the textbook. 33

Unit 3: The C in C++ Back to top -- C++ is based on the C programming language. This unit examines the relationship between the two languages. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Section 8 Section 9 Section 10 Section 11 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 3 in the textbook. For the problems 2, 4, 10, 14, 22, 24, 32, and 34, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 3 topic. 34

Unit 3 - Section 1 : Creating functions Back to Unit 3 A look at the way function prototyping has improved the creation of functions in C and C++. define a function prototype; list the components of a function prototype; describe function return values; describe the C function library; describe the librarian. Define function prototype. List the components of a function prototype. Describe the range of possible function return values. Describe the C function library and its purpose. Describe the librarian. Exercises 35

Unit 3 - Section 2 : Controlling execution Back to Unit 3 Execution control statements are similar in C and C++. list the five execution control statements in C; define the if-else statement; define the while statement; define the do-while statement; define the for statement; define the switch statement; define the C++ specific goto statement, and discuss why this statement is avoided in C++ programming; define recursion. List the five execution control statements in C. Define the if-else statement. Define the while statement. Define the do-while statement. Define the for statement. Define the switch statement. Define the C++ specific goto statement, and discuss why this statement is avoided in C++ programming. Define recursion. 36

Unit 3 - Section 3 : Introduction to operators Back to Unit 3 Operators take one or two values, and produce a new value. list the basic operators; define precedence, and describe the use of parentheses to change precedence; define the auto increment and decrement operators. List the basic operators. Define precedence, and describe the use of parentheses to change precedence. Define the auto increment and decrement operators. 37

Unit 3 - Section 4 : Introduction to data types Back to Unit 3 Data types define the way in which information is stored and used in the programs we write. list the basic built-in data types for C++; describe the bool data type; list the specifiers in C++; describe pointers in C++; describe references in C++. List the basic data types for C++. What is the purpose of the bool data type? List the specifiers introduced in the readings. Define the term pointer, as it is used in C++. Define the term reference, as it is used in C++. Describe one of the purposes of the pointer. Compare the pointer to the reference in C++. What is the primary difference between the two? 38

Unit 3 - Section 5 : Scoping Back to Unit 3 Scoping rules tell the programmer where variables are valid, where they are created, and where they are destroyed. explain the phrase "goes out of scope"; describe the procedure for defining a variable on the fly. What is meant by the phrase "goes out of scope"? Describe the procedure for defining a variable on the fly. 39

Unit 3 - Section 6 : Specifying storage allocation Back to Unit 3 When creating a variable, there are many options for specifying the lifetime of the variable, the allocation of memory (storage), and handling of the variable by the compiler. define the term global variable; list the steps used to create a global variable; define the term local variable; list the steps used to create a local variable; define the term static; define the keyword extern; define the keyword const; define the keyword volatile; discuss the linkage of variables in relation to the terms static, extern, and const. Define the term global variable. List the steps used to create a global variable. Define the term local variable. List the steps used to create a local variable. Define the term static. Define the keyword extern. Define the keyword const. Define the keyword volatile. What is the difference between a variable created using the const keyword and one created using the volatile keyword? Static and volatile? 40

Unit 3 - Section 7 : Operators and their use Back to Unit 3 This section covers all of the operators in C and C++. list and define the mathematical operators; list and define the relational operators; list and define the logical operators; list and define the bitwise operators; list and define the shift operators; list and define the unary operators; list and define the ternary operator; list and define the comma operator; describe some common pitfalls when using operators; list and define the casting operators; list and define the C++ explicit casts; list and define the static_cast; list and define the const_cast; list and define the reinterpret_cast; list and define the sizeof operator; list and define the asm keyword; list and define the explicit operators. List and define the mathematical operators. List and define the relational operators. List and define the logical operators. List and define the bitwise operators. List and define the shift operators. List and define the unary operators. List and define the ternary operator. 41

List and define the comma operator. Describe some common pitfalls when using operators. List and define the casting operators. List and define the C++ explicit casts. List and define the static_cast. List and define the const_cast. List and define the reinterpret_cast. List and define the sizeof operator. List and define the asm keyword. List and define the explicit operators. 42

Unit 3 - Section 8 : Composite type creation Back to Unit 3 Composition allows the programmer to compose more sophisticated data types by combining fundamental data types. define aliasing; define typedef, and describe how it is used to create aliases; describe how variables can be combined using struct; define enum, and describe how it can be used to clarify programs; define union, and describe how it can be used to save memory; define arrays; describe how arrays use pointers; describe pointer arithmetic. Define aliasing. Define typedef, and describe how it is used to create aliases. Describe how variables can be combined using struct. Define enum, and describe how it can be used to clarify programs. Define union, and describe how it can be used to save memory. Define arrays. Describe how arrays use pointers. Describe pointer arithmetic. 43

Unit 3 - Section 9 : Debugging hints Back to Unit 3 This section describes how to debug your code when no debugging tool is available. describe preprocessor debugging flags; describe runtime debugging flags; describe the process used to turn variables and expressions into strings; define the C assert() macro. Describe preprocessor debugging flags. Describe runtime debugging flags. Describe the process used to turn variables and expressions into strings. Define the C assert() macro. 44

Unit 3 - Section 10 : Function addresses Back to Unit 3 This section describes how a programmer may obtain and use the memory address for a compiled function. define a function pointer; list the steps involved in using a function pointer; list the steps involved in creating arrays of function pointers. Define a function pointer. List the steps involved in using a function pointer. List the steps involved in creating arrays of function pointers. 45

Unit 3 - Section 11 : Make: managing separate compilation Back to Unit 3 Make is a utility that allows the programmer to manage the compilation and linking of separate program units (source files) and libraries. define separate compilation; list the make activities; define a makefile; define macros; define default targets in a makefile. Define separate compilation. List the make activities. Define a makefile. Define macros. Define default targets in a makefile. Examine and test the example makefiles from this chapter of the textbook, using the downloaded example suite from www.bruceeckel.com 46

Unit 4: Data Abstraction Back to top -- Creating new data types is one of the powerful features of C++. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Section 8 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 4 in the textbook. For the problems 8, 12, 16, 18, and 22, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 4 topic. 47

Unit 4 - Section 1 : A tiny C-like library Back to Unit 4 The library CStash is an example of a struct-based library. describe the CStash library; define dynamic storage allocation; list several C and C++ dynamic storage keywords. What is the CStash library? Define dynamic storage allocation. List several C and C++ dynamic storage keywords Exercises 48

Unit 4 - Section 2 : What's wrong? Back to Unit 4 Name clashes need to be identified and corrected. list the name clashes that occur in the CStash library. List the name clashes that occur in the CStash library. 49

Unit 4 - Section 3 : The basic object Back to Unit 4 C++ functions can be placed inside structs as member functions. This creates the basic C++ object. list the differences between CStash and C++ Stash. List the differences between CStash and C++ Stash. 50

Unit 4 - Section 4 : What's an object? Back to Unit 4 The C++ definition of an object is explored. define an object in C++ terminology. Define an object in C++ terminology. 51

Unit 4 - Section 5 : Abstract data typing Back to Unit 4 Packaging data with functions creates a new data type, and is termed encapsulation. list the new abstract data type that is defined in Stash. List the new abstract data type that is defined in Stash. 52

Unit 4 - Section 6 : Object details Back to Unit 4 The differences between a C++ object and a struct are explored. list the differences between a C++ object and a struct. List the differences between a C++ object and a struct. 53

Unit 4 - Section 7 : Header file etiquette Back to Unit 4 Header files can be used to separate the interface of an object from the implementation. define an object's interface; define an object's implementation; describe the importance of header files; describe the multiple-declaration problem; define the preprocessor directives #define, #ifdef, and #endif; describe Eckel's standard for header files; define namespaces in headers. Define an object's interface. Define an object's implementation. Describe the importance of header files. Describe the multiple-declaration problem. Define the preprocessor directives #define, #ifdef, and #endif. Describe Eckel's standard for header files. Define namespaces in headers. 54

Unit 4 - Section 8 : Nested structures Back to Unit 4 It is possible to nest one structure inside another structure. describe the nesting of structures. Describe the nesting of structures. 55

Unit 5: Hiding the Implementation Back to top -- Issues of safety and control are important when creating libraries that employ structures. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 5 in the textbook. For the problems 6, 10, 12, and 14, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 5 topic. 56

Unit 5 - Section 1 : Setting limits Back to Unit 5 Libraries represent a relationship with the client programmer. Boundaries are essential to that relationship. list the two reasons to control access to structure members. List the two reasons to control access to structure members. Exercises 57

Unit 5 - Section 2 : C++ access control Back to Unit 5 Access control in C++ is accomplished with three keywords: public, private, and protected. define the access control keywords: public, private, and protected. Define the access control keywords: public, private, and protected. 58

Unit 5 - Section 3 : Friends Back to Unit 5 Friend access allows a program gain access to another function that is not in the current structure. define the friend keyword; describe nested friends. Define the friend keyword. Describe nested friends. 59

Unit 5 - Section 4 : Object layout Back to Unit 5 This section describes the difference between the object layout of a C struct and a C++ struct. describe the differences in layout between a C struct and a C++ struct. Describe the differences in layout between a C struct and a C++ struct. 60

Unit 5 - Section 5 : The class Back to Unit 5 The C++ class is the logical extension of the struct. define the class in C++; list at least two ways in which the C++ class differs from the C struct; list at least two ways in which the C++ class differs from the C++ struct; observe how the example programs Stash and Stack are changed to use access control. Define the class in C++. List at least two ways in which the C++ class differs from the C struct. List at least two ways in which the C++ class differs from the C++ struct. 61

Unit 5 - Section 6 : Handle classes Back to Unit 5 This section considers the topic of complete implementation hiding. define complete implementation hiding. Define complete implementation hiding. 62

Unit 6: Initialization & Cleanup Back to top -- Continuing the topic of encapsulation and code safety, this unit examines class initialization and cleanup. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 6 in the textbook. For the problems 2, 6, 8, and 10, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 6 topic. 63

Unit 6 - Section 1 : Guaranteed initialization with the constructor Back to Unit 6 The constructor is the mechanism used by C++ class to guarantee object initialization. define the term constructor. Define the term constructor. Exercises 64

Unit 6 - Section 2 : Guaranteed cleanup with the destructor Back to Unit 6 The destructor is the mechanism used by C++ class to guarantee object cleanup. define the term destructor. Define the term destructor. 65

Unit 6 - Section 3 : Elimination of the definition block Back to Unit 6 C++ allows the programmer to dispense with the standard variable definition block at the start of a code block. define the term definition block; list at least two reasons to dispense with the definition block; describe the lifetime of loop variables. Define the term definition block. List at least two reasons to dispense with the definition block. Describe the lifetime of loop variables. 66

Unit 6 - Section 4 : Stash with constructors and destructors Back to Unit 6 The example program Stash is presented using constructors and destructors. describe the effect of constructors and destructors on the example program Stash. How does the program Stash change when constructors and destructors are employed? 67

Unit 6 - Section 5 : Stack with constructors & destructors Back to Unit 6 The example program Stack is presented using constructors and destructors. describe the effect of constructors and destructors on the example program Stack. How does the program Stack change when constructors and destructors are employed? 68

Unit 6 - Section 6 : Aggregate initialization Back to Unit 6 C++ provides a convenient mechanism to initialize aggregates. define the term aggregate in C++; list the aggregate types in C++ discussed in this section of the readings; list the ways in which each aggregate type is initialized in C++. Define the term aggregate in C++. List the aggregate types in C++ discussed in this section of the readings. List the ways in which each aggregate type is initialized in C++. 69

Unit 6 - Section 7 : Default constructors Back to Unit 6 A default constructor is one that can be called with no arguments. define the term default constructor. Define the term default constructor. 70

Unit 7: Function Overloading & Default Arguments Back to top -- C++ allows the programmer to create convenient areas of named storage. Section 1 Section 2 Section 3 Section 4 Section 5 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 7 in the textbook. For the problems 6, 8, and 10, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 7 topic. 71

Unit 7 - Section 1 : More name decoration Back to Unit 7 Function name decoration is explored in greater detail. define the term function name decoration; explain why return values cannot be overloaded in C++; define the term type-safe linkage. Define the term function name decoration. Explain why return values cannot be overloaded in C++. Define the term type-safe linkage. Exercises 72

Unit 7 - Section 2 : Overloading example Back to Unit 7 This section demonstrates the program Stash employing overloading. describe the effect of using overloading in the example program Stash. 73

Unit 7 - Section 3 : unions Back to Unit 7 Like the C++ struct, the union in C++ can have constructors, destructors, and member functions. define union; list at least two differences between union and class. Define union. List at least two differences between union and class. 74

Unit 7 - Section 4 : Default arguments Back to Unit 7 Default arguments allow the constructor to provide flexible initialization of a class. define the term default arguments; define the term placeholder arguments. Define the term default arguments. Define the term placeholder arguments. 75

Unit 7 - Section 5 : Choosing overloading vs. default arguments Back to Unit 7 This section provides guidelines for choosing overloading versus default arguments for a class. list at least two reasons why a programmer would choose overloading instead of default arguments; list at least two reasons why a programmer would choose default arguments instead of overloading. List at least two reasons why a programmer would choose overloading instead of default arguments. List at least two reasons why a programmer would choose default arguments instead of overloading. 76

Unit 8: Constants Back to top -- Constants provide safety and control in C++ by allowing the programmer to distinguish between what changes and what does not change. Section 1 Section 2 Section 3 Section 4 Section 5 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 8 in the textbook. For the problems 6, 10, 12, 16, 22, and 26, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 8 topic. 77

Unit 8 - Section 1 : Value substitution Back to Unit 8 Value substitution is provided by the C++ preprocessor, but does not provide the safety of const. list the steps to create a preprocessor substitution; list the steps to use a const in a header file; describe why const does not work with aggregates; list at least two differences between C and C++ in the handling of const. List the steps to create a preprocessor substitution. List the steps to use a const in a header file. Describe why const does not work with aggregates. List at least two differences between C and C++ in the handling of const. Exercises 78

Unit 8 - Section 2 : Pointers Back to Unit 8 Pointers can be const, which can add to their safety. list two options to make a pointer const; define pointer to const; define const pointer; discuss where and when type checking is enforced when using const. List two options to make a pointer const. Define pointer to const. Define const pointer. List at least two places where type checking is enforced when using const. When is type checking not enforced when using const? 79

Unit 8 - Section 3 : Function arguments & return values Back to Unit 8 Using const with function arguments and return values is an area where care must be exercised. define passing by const value; define returning by const value; define temporary objects; define passing addresses; define returning addresses; define standard argument passing. Define passing by const value. Define returning by const value. Define temporary objects. Define passing addresses. Define returning addresses. Define standard argument passing. 80

Unit 8 - Section 4 : Classes Back to Unit 8 This section demonstrates the use of const with classes. list at least two uses of const in a class; define constructor initializer list; list at least two examples of a constructor for a built-in type; define the keyword static const; define the term const object. List at least two uses of const in a class. Define constructor initializer list. List at least two examples of a constructor for a built-in type. Define the keyword static const. Define the term const object. 81

Unit 8 - Section 5 : volatile Back to Unit 8 Both const and volatile have the same syntax, but volatile tells the compiler not to make any assumptions about the data. define the keyword volatile; define the keyword const volatile. Define the keyword volatile. Define the keyword const volatile. 82

Unit 9: Inline Functions Back to top -- Inline functions preserve the efficiency of the macro while adding the safety and class scoping of functions. Section 1 Section 2 Section 3 Section 4 Section 5 Section 6 Section 7 Tasks Be sure to use the course conference to confer with your fellow students. The conference is a place where you can ask questions about the course, answer questions that others have asked, discuss topics related to the course, and meet with other students taking this course. Exercises There are a number of Exercises at the end of Chapter 9 in the textbook. For the problems 2, 8, 12, 16, and 18, design, code, compile, and test C++ programs to meet the requirements of these problems. Share your solutions with students in the course conference under the Unit 9 topic. 83

Unit 9 - Section 1 : Preprocessor pitfalls Back to Unit 9 Preprocessor macros are efficient, but are not without pitfalls. list the pitfalls of preprocessor macros. List the pitfalls of preprocessor macros. Exercises 84

Unit 9 - Section 2 : Inline functions Back to Unit 9 C++ implements the macro as an inline function. define inline function; list the benefits of inline functions over macros; list the steps to creating an inline function; list the steps to creating an inline function inside a class; define access function; define the terms accessor and mutator. Define inline function. List the benefits of inline functions over macros. List the steps to creating an inline function. List the steps to creating an inline function inside a class. Define access function. Define the terms accessor and mutator. 85

Unit 9 - Section 3 : Stash & Stack with inlines Back to Unit 9 The example program Stash is presented using inline functions. describe the effect of inline functions in the example program Stash. List at least two ways in which the use of inline functions improves the example program Stash. 86

Unit 9 - Section 4 : Inlines & the compiler Back to Unit 9 The manner in which the compiler treats an inline function allows the development of guidelines concerning their use. list the steps the compiler takes when it encounters an inline function; list the two limitations of inline functions; define forward reference. List the steps the compiler takes when it encounters an inline function. List the two limitations of inline functions. Define forward reference. 87