Computer Science 306 Study Guide

Size: px
Start display at page:

Download "Computer Science 306 Study Guide"

Transcription

1 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

2 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

3 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

4 Copyright and Credits: Back to top Copyright Correspondence can be directed to Copyright Office Athabasca University 1 University Drive Athabasca AB T9S 3A3 Website: copyright@athabascau.ca When linking to a specific page on this site (deep-linking), please also link to the main site at: 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

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

6 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

7 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

8 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

9 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

10 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

11 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

12 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

13 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

14 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

15 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

16 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

17 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

18 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

19 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

20 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

21 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

22 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

23 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

24 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

25 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

26 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

27 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

28 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

29 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

30 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

31 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

32 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

33 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

34 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

35 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

36 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

37 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

38 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

39 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

40 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

41 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

42 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

43 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

44 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

45 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

46 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 46

47 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

48 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

49 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

50 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

51 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

52 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

53 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

54 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

55 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

56 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

57 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

58 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

59 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

60 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

61 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

62 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

63 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

64 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

65 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

66 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

67 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

68 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

69 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

70 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

71 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

72 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

73 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

74 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

75 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

76 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

77 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

78 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

79 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

80 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

81 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

82 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

83 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

84 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

85 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

86 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

87 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

Short Notes of CS201

Short Notes of CS201 #includes: Short Notes of CS201 The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with < and > if the file is a system

More information

CS201 - Introduction to Programming Glossary By

CS201 - Introduction to Programming Glossary By CS201 - Introduction to Programming Glossary By #include : The #include directive instructs the preprocessor to read and include a file into a source code file. The file name is typically enclosed with

More information

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

C++ (Non for C Programmer) (BT307) 40 Hours C++ (Non for C Programmer) (BT307) 40 Hours Overview C++ is undoubtedly one of the most widely used programming language for implementing object-oriented systems. The C++ language is based on the popular

More information

Absolute C++ Walter Savitch

Absolute C++ Walter Savitch Absolute C++ sixth edition Walter Savitch Global edition This page intentionally left blank Absolute C++, Global Edition Cover Title Page Copyright Page Preface Acknowledgments Brief Contents Contents

More information

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

Welcome to Teach Yourself Acknowledgments Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. Welcome to Teach Yourself p. viii Acknowledgments p. xv Fundamental C++ Programming p. 2 An Introduction to C++ p. 4 A Brief History of C++ p. 6 Standard C++: A Programming Language and a Library p. 8

More information

Practical C++ Programming

Practical C++ Programming SECOND EDITION Practical C++ Programming Steve Oualline O'REILLY' Beijing Cambridge Farnham Koln Paris Sebastopol Taipei Tokyo Preface xv Part I. The Basics 1. What Is C++? 3 A Brief History of C++ 3 C++

More information

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

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 Introduction p. xxix 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 Language p. 6 C Is a Programmer's Language

More information

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING

STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING OBJECT ORIENTED PROGRAMMING STUDY NOTES UNIT 1 - INTRODUCTION TO OBJECT ORIENTED PROGRAMMING 1. Object Oriented Programming Paradigms 2. Comparison of Programming Paradigms 3. Basic Object Oriented Programming

More information

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

C++ Coding Standards. 101 Rules, Guidelines, and Best Practices. Herb Sutter Andrei Alexandrescu. Boston. 'Y.'YAddison-Wesley C++ Coding Standards 101 Rules, Guidelines, and Best Practices Herb Sutter Andrei Alexandrescu 'Y.'YAddison-Wesley Boston Contents Prefaee xi Organizational and Poliey Issues 1 o. Don't sweat the small

More information

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

Cpt S 122 Data Structures. Introduction to C++ Part II Cpt S 122 Data Structures Introduction to C++ Part II Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Topics Objectives Defining class with a member function

More information

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

Learning Objectives. C++ For Artists 2003 Rick Miller All Rights Reserved xli Identify and overcome the difficulties encountered by students when learning how to program List and explain the software development roles played by students List and explain the phases of the tight spiral

More information

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

OBJECT ORIENTED PROGRAMMING USING C++ CSCI Object Oriented Analysis and Design By Manali Torpe OBJECT ORIENTED PROGRAMMING USING C++ CSCI 5448- Object Oriented Analysis and Design By Manali Torpe Fundamentals of OOP Class Object Encapsulation Abstraction Inheritance Polymorphism Reusability C++

More information

CERTIFICATE IN WEB PROGRAMMING

CERTIFICATE IN WEB PROGRAMMING COURSE DURATION: 6 MONTHS CONTENTS : CERTIFICATE IN WEB PROGRAMMING 1. PROGRAMMING IN C and C++ Language 2. HTML/CSS and JavaScript 3. PHP and MySQL 4. Project on Development of Web Application 1. PROGRAMMING

More information

Instantiation of Template class

Instantiation of Template class Class Templates Templates are like advanced macros. They are useful for building new classes that depend on already existing user defined classes or built-in types. Example: stack of int or stack of double

More information

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

Appendix. Grammar. A.1 Introduction. A.2 Keywords. There is no worse danger for a teacher than to teach words instead of things. A Appendix Grammar There is no worse danger for a teacher than to teach words instead of things. Marc Block Introduction keywords lexical conventions programs expressions statements declarations declarators

More information

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

C Programming. Course Outline. C Programming. Code: MBD101. Duration: 10 Hours. Prerequisites: C Programming Code: MBD101 Duration: 10 Hours Prerequisites: You are a computer science Professional/ graduate student You can execute Linux/UNIX commands You know how to use a text-editing tool You should

More information

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

Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns Advanced C++ Programming Workshop (With C++11, C++14, C++17) & Design Patterns This Advanced C++ Programming training course is a comprehensive course consists of three modules. A preliminary module reviews

More information

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

OOPS Viva Questions. Object is termed as an instance of a class, and it has its own state, behavior and identity. OOPS Viva Questions 1. What is OOPS? OOPS is abbreviated as Object Oriented Programming system in which programs are considered as a collection of objects. Each object is nothing but an instance of a class.

More information

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

QUIZ. What are 3 differences between C and C++ const variables? QUIZ What are 3 differences between C and C++ const variables? Solution QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Solution The C/C++ preprocessor substitutes mechanically,

More information

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR

SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR SRM ARTS AND SCIENCE COLLEGE SRM NAGAR, KATTANKULATHUR 603203 DEPARTMENT OF COMPUTER SCIENCE & APPLICATIONS QUESTION BANK (2017-2018) Course / Branch : M.Sc CST Semester / Year : EVEN / II Subject Name

More information

C++ for System Developers with Design Pattern

C++ for System Developers with Design Pattern C++ for System Developers with Design Pattern Introduction: This course introduces the C++ language for use on real time and embedded applications. The first part of the course focuses on the language

More information

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

Cpt S 122 Data Structures. Course Review Midterm Exam # 2 Cpt S 122 Data Structures Course Review Midterm Exam # 2 Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Midterm Exam 2 When: Monday (11/05) 12:10 pm -1pm

More information

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

QUIZ. What is wrong with this code that uses default arguments? QUIZ What is wrong with this code that uses default arguments? Solution The value of the default argument should be placed in either declaration or definition, not both! QUIZ What is wrong with this code

More information

QUIZ. How could we disable the automatic creation of copyconstructors

QUIZ. How could we disable the automatic creation of copyconstructors QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. Ch. 14: Inheritance

More information

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

Preface to the Second Edition Preface to the First Edition Brief Contents Introduction to C++ p. 1 A Review of Structures p. Preface to the Second Edition p. iii Preface to the First Edition p. vi Brief Contents p. ix Introduction to C++ p. 1 A Review of Structures p. 1 The Need for Structures p. 1 Creating a New Data Type Using

More information

CGS 2405 Advanced Programming with C++ Course Justification

CGS 2405 Advanced Programming with C++ Course Justification Course Justification This course is the second C++ computer programming course in the Computer Science Associate in Arts degree program. This course is required for an Associate in Arts Computer Science

More information

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

CHAPTER 1 Introduction to Computers and Programming CHAPTER 2 Introduction to C++ ( Hexadecimal 0xF4 and Octal literals 031) cout Object CHAPTER 1 Introduction to Computers and Programming 1 1.1 Why Program? 1 1.2 Computer Systems: Hardware and Software 2 1.3 Programs and Programming Languages 8 1.4 What is a Program Made of? 14 1.5 Input,

More information

QUIZ. How could we disable the automatic creation of copyconstructors

QUIZ. How could we disable the automatic creation of copyconstructors QUIZ How could we disable the automatic creation of copyconstructors pre-c++11? What syntax feature did C++11 introduce to make the disabling clearer and more permanent? Give a code example. QUIZ How

More information

CS304 Object Oriented Programming Final Term

CS304 Object Oriented Programming Final Term 1. Which of the following is the way to extract common behaviour and attributes from the given classes and make a separate class of those common behaviours and attributes? Generalization (pg 29) Sub-typing

More information

Interview Questions of C++

Interview Questions of C++ Interview Questions of C++ Q-1 What is the full form of OOPS? Ans: Object Oriented Programming System. Q-2 What is a class? Ans: Class is a blue print which reflects the entities attributes and actions.

More information

Introduction to C++ Systems Programming

Introduction to C++ Systems Programming Introduction to C++ Systems Programming Introduction to C++ Syntax differences between C and C++ A Simple C++ Example C++ Input/Output C++ Libraries C++ Header Files Another Simple C++ Example Inline Functions

More information

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

B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET B.C.A 2017 OBJECT ORIENTED PROGRAMMING USING C++ BCA303T MODULE SPECIFICATION SHEET Course Outline The main objective of this course is to introduce students to the basic concepts of a selected language

More information

Problem Solving with C++

Problem Solving with C++ GLOBAL EDITION Problem Solving with C++ NINTH EDITION Walter Savitch Kendrick Mock Ninth Edition PROBLEM SOLVING with C++ Problem Solving with C++, Global Edition Cover Title Copyright Contents Chapter

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

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

Ch. 3: The C in C++ - Continued - Ch. 3: The C in C++ - Continued - QUIZ What are the 3 ways a reference can be passed to a C++ function? QUIZ True or false: References behave like constant pointers with automatic dereferencing. QUIZ What

More information

Lecture Notes on Programming Languages

Lecture Notes on Programming Languages Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered

More information

III. Classes (Chap. 3)

III. Classes (Chap. 3) III. Classes III-1 III. Classes (Chap. 3) As we have seen, C++ data types can be classified as: Fundamental (or simple or scalar): A data object of one of these types is a single object. int, double, char,

More information

G52CPP C++ Programming Lecture 9

G52CPP C++ Programming Lecture 9 G52CPP C++ Programming Lecture 9 Dr Jason Atkin http://www.cs.nott.ac.uk/~jaa/cpp/ g52cpp.html 1 Last lecture const Constants, including pointers The C pre-processor And macros Compiling and linking And

More information

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

RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING QUESTION BANK UNIT I 2 MARKS RAJIV GANDHI COLLEGE OF ENGINEERING AND TECHNOLOGY DEPARTMENT OF INFORMATION TECHNOLOGY OBJECT ORIENTED PROGRAMMING YEAR/SEM:II & III UNIT I 1) Give the evolution diagram of OOPS concept. 2) Give some

More information

Get Unique study materials from

Get Unique study materials from Downloaded from www.rejinpaul.com VALLIAMMAI ENGNIEERING COLLEGE SRM Nagar, Kattankulathur 603203. DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING Year & Semester : IV Section : EEE - 1 & 2 Subject Code

More information

About Codefrux While the current trends around the world are based on the internet, mobile and its applications, we try to make the most out of it. As for us, we are a well established IT professionals

More information

UEE1302 (1102) F10: Introduction to Computers and Programming

UEE1302 (1102) F10: Introduction to Computers and Programming Computational Intelligence on Automation Lab @ NCTU Learning Objectives UEE1302 (1102) F10: Introduction to Computers and Programming Programming Lecture 00 Programming by Example Introduction to C++ Origins,

More information

Object-Oriented Design (OOD) and C++

Object-Oriented Design (OOD) and C++ Chapter 2 Object-Oriented Design (OOD) and C++ At a Glance Instructor s Manual Table of Contents Chapter Overview Chapter Objectives Instructor Notes Quick Quizzes Discussion Questions Projects to Assign

More information

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.

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. 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. 9 Self-Test Exercises p. 11 History Note p. 12 Programming and

More information

Review of the C Programming Language

Review of the C Programming Language Review of the C Programming Language Prof. James L. Frankel Harvard University Version of 11:55 AM 22-Apr-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights reserved. Reference Manual for the

More information

Review of the C Programming Language for Principles of Operating Systems

Review of the C Programming Language for Principles of Operating Systems Review of the C Programming Language for Principles of Operating Systems Prof. James L. Frankel Harvard University Version of 7:26 PM 4-Sep-2018 Copyright 2018, 2016, 2015 James L. Frankel. All rights

More information

STRUCTURING OF PROGRAM

STRUCTURING OF PROGRAM Unit III MULTIPLE CHOICE QUESTIONS 1. Which of the following is the functionality of Data Abstraction? (a) Reduce Complexity (c) Parallelism Unit III 3.1 (b) Binds together code and data (d) None of the

More information

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

KLiC C++ Programming. (KLiC Certificate in C++ Programming) KLiC C++ Programming (KLiC Certificate in C++ Programming) Turbo C Skills: Pre-requisite Knowledge and Skills, Inspire with C Programming, Checklist for Installation, The Programming Languages, The main

More information

Variables. Data Types.

Variables. Data Types. Variables. Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable. We had to write several lines of code, compile them, and then execute the resulting

More information

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

Paytm Programming Sample paper: 1) A copy constructor is called. a. when an object is returned by value Paytm Programming Sample paper: 1) A copy constructor is called a. when an object is returned by value b. when an object is passed by value as an argument c. when compiler generates a temporary object

More information

AN OVERVIEW OF C++ 1

AN OVERVIEW OF C++ 1 AN OVERVIEW OF C++ 1 OBJECTIVES Introduction What is object-oriented programming? Two versions of C++ C++ console I/O C++ comments Classes: A first look Some differences between C and C++ Introducing function

More information

2. COURSE DESIGNATION: 3. COURSE DESCRIPTIONS:

2. COURSE DESIGNATION: 3. COURSE DESCRIPTIONS: College of San Mateo Official Course Outline 1. COURSE ID: CIS 278 TITLE: (CS1) Programming Methods: C++ C-ID: COMP 122 Units: 4.0 units Hours/Semester: 48.0-54.0 Lecture hours; 48.0-54.0 Lab hours; and

More information

VALLIAMMAI ENGINEERING COLLEGE

VALLIAMMAI ENGINEERING COLLEGE VALLIAMMAI ENGINEERING COLLEGE SRM Nagar, Kattankulathur 603 203 DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING QUESTION BANK B.E. - Electrical and Electronics Engineering IV SEMESTER CS6456 - OBJECT ORIENTED

More information

What are the characteristics of Object Oriented programming language?

What are the characteristics of Object Oriented programming language? What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is

More information

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

Chapter 15 - C++ As A Better C Chapter 15 - C++ As A "Better C" Outline 15.1 Introduction 15.2 C++ 15.3 A Simple Program: Adding Two Integers 15.4 C++ Standard Library 15.5 Header Files 15.6 Inline Functions 15.7 References and Reference

More information

Fast Introduction to Object Oriented Programming and C++

Fast Introduction to Object Oriented Programming and C++ Fast Introduction to Object Oriented Programming and C++ Daniel G. Aliaga Note: a compilation of slides from Jacques de Wet, Ohio State University, Chad Willwerth, and Daniel Aliaga. Outline Programming

More information

Tokens, Expressions and Control Structures

Tokens, Expressions and Control Structures 3 Tokens, Expressions and Control Structures Tokens Keywords Identifiers Data types User-defined types Derived types Symbolic constants Declaration of variables Initialization Reference variables Type

More information

September 10,

September 10, September 10, 2013 1 Bjarne Stroustrup, AT&T Bell Labs, early 80s cfront original C++ to C translator Difficult to debug Potentially inefficient Many native compilers exist today C++ is mostly upward compatible

More information

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE

CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE CS 6456 OBJCET ORIENTED PROGRAMMING IV SEMESTER/EEE PART A UNIT I 1. Differentiate object oriented programming from procedure oriented programming. 2. Define abstraction and encapsulation. 3. Differentiate

More information

Object Oriented Programming with c++ Question Bank

Object Oriented Programming with c++ Question Bank Object Oriented Programming with c++ Question Bank UNIT-1: Introduction to C++ 1. Describe the following characteristics of OOP. i Encapsulation ii Polymorphism, iii Inheritance 2. Discuss function prototyping,

More information

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

Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Java for Programmers Course (equivalent to SL 275) 36 Contact Hours Course Overview This course teaches programmers the skills necessary to create Java programming system applications and satisfies the

More information

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

Intro to OOP Visibility/protection levels and constructors Friend, convert constructor, destructor Operator overloading a<=b a. Intro to OOP - Object and class - The sequence to define and use a class in a program - How/when to use scope resolution operator - How/when to the dot operator - Should be able to write the prototype

More information

QUIZ. Source:

QUIZ. Source: QUIZ Source: http://stackoverflow.com/questions/17349387/scope-of-macros-in-c Ch. 4: Data Abstraction The only way to get massive increases in productivity is to leverage off other people s code. That

More information

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

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

More information

CE221 Programming in C++ Part 1 Introduction

CE221 Programming in C++ Part 1 Introduction CE221 Programming in C++ Part 1 Introduction 06/10/2017 CE221 Part 1 1 Module Schedule There are two lectures (Monday 13.00-13.50 and Tuesday 11.00-11.50) each week in the autumn term, and a 2-hour lab

More information

Object-Oriented Programming

Object-Oriented Programming Object-Oriented Programming 1. What is object-oriented programming (OOP)? OOP is a technique to develop logical modules, such as classes that contain properties, methods, fields, and events. An object

More information

ECE 3574: Dynamic Polymorphism using Inheritance

ECE 3574: Dynamic Polymorphism using Inheritance 1 ECE 3574: Dynamic Polymorphism using Inheritance Changwoo Min 2 Administrivia Survey on class will be out tonight or tomorrow night Please, let me share your idea to improve the class! 3 Meeting 10:

More information

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

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix PGJC4_JSE8_OCA.book Page ix Monday, June 20, 2016 2:31 PM Contents Figures Tables Examples Foreword Preface xix xxi xxiii xxvii xxix 1 Basics of Java Programming 1 1.1 Introduction 2 1.2 Classes 2 Declaring

More information

2 ADT Programming User-defined abstract data types

2 ADT Programming User-defined abstract data types Preview 2 ADT Programming User-defined abstract data types user-defined data types in C++: classes constructors and destructors const accessor functions, and inline functions special initialization construct

More information

CS 376b Computer Vision

CS 376b Computer Vision CS 376b Computer Vision 09 / 25 / 2014 Instructor: Michael Eckmann Today s Topics Questions? / Comments? Enhancing images / masks Cross correlation Convolution C++ Cross-correlation Cross-correlation involves

More information

CS3157: Advanced Programming. Outline

CS3157: Advanced Programming. Outline CS3157: Advanced Programming Lecture #12 Apr 3 Shlomo Hershkop shlomo@cs.columbia.edu 1 Outline Intro CPP Boring stuff: Language basics: identifiers, data types, operators, type conversions, branching

More information

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

QUIZ. Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? QUIZ Write the following for the class Bar: Default constructor Constructor Copy-constructor Overloaded assignment oper. Is a destructor needed? Or Foo(x), depending on how we want the initialization

More information

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

dewhurst_index.qxd 10/16/02 1:54 PM Page 309 Index dewhurst_index.qxd 10/16/02 1:54 PM Page 309 Index, (comma operator), 39 40?: (conditional operator), 15 16, 40 41 [ ] (allocating and deleting arrays), 35, 36, 168 ( ) (allocating arrays), 35 -> (arrow

More information

C++ Important Questions with Answers

C++ Important Questions with Answers 1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children

More information

Compulsory course in Computer Science

Compulsory course in Computer Science Compulsory course in Computer Science University of Macau Faculty of Science and Technology Department of Computer and Information Science SFTW241 Programming Languages Architecture I Syllabus 2 nd Semester

More information

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

The Design Process. General Development Issues. C/C++ and OO Rules of Thumb. Home A l l e n I. H o l u b & A s s o c i a t e s Home C/C++ and OO Rules of Thumb The following list is essentially the table of contents for my book Enough Rope to Shoot Yourself in the Foot (McGraw-Hill,

More information

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

C++ Programming: From Problem Analysis to Program Design, Fifth Edition. Chapter 12: Classes and Data Abstraction C++ Programming: From Problem Analysis to Program Design, Fifth Edition Chapter 12: Classes and Data Abstraction Objectives In this chapter, you will: Learn about classes Learn about private, protected,

More information

Table of Contents Preface Bare Necessities... 17

Table of Contents Preface Bare Necessities... 17 Table of Contents Preface... 13 What this book is about?... 13 Who is this book for?... 14 What to read next?... 14 Personages... 14 Style conventions... 15 More information... 15 Bare Necessities... 17

More information

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

I BSc(IT) [ Batch] Semester II Core: Object Oriented Programming With C plus plus - 212A Multiple Choice Questions. Dr.G.R.Damodaran College of Science (Autonomous, affiliated to the Bharathiar University, recognized by the UGC)Reaccredited at the 'A' Grade Level by the NAAC and ISO 9001:2008 Certified CRISL rated 'A'

More information

IS 0020 Program Design and Software Tools

IS 0020 Program Design and Software Tools 1 IS 0020 Program Design and Software Tools Introduction to C++ Programming Spring 2005 Lecture 1 Jan 6, 2005 Course Information 2 Lecture: James B D Joshi Tuesdays/Thursdays: 1:00-2:15 PM Office Hours:

More information

CprE 288 Introduction to Embedded Systems Exam 1 Review. 1

CprE 288 Introduction to Embedded Systems Exam 1 Review.  1 CprE 288 Introduction to Embedded Systems Exam 1 Review http://class.ece.iastate.edu/cpre288 1 Overview of Today s Lecture Announcements Exam 1 Review http://class.ece.iastate.edu/cpre288 2 Announcements

More information

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

QUIZ How do we implement run-time constants and. compile-time constants inside classes? QUIZ How do we implement run-time constants and compile-time constants inside classes? Compile-time constants in classes The static keyword inside a class means there s only one instance, regardless of

More information

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

Ch02. True/False Indicate whether the statement is true or false. Ch02 True/False Indicate whether the statement is true or false. 1. The base class inherits all its properties from the derived class. 2. Inheritance is an is-a relationship. 3. In single inheritance,

More information

Ch. 12: Operator Overloading

Ch. 12: Operator Overloading Ch. 12: Operator Overloading Operator overloading is just syntactic sugar, i.e. another way to make a function call: shift_left(42, 3); 42

More information

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

Lesson Plan. Subject: OBJECT ORIENTED PROGRAMMING USING C++ :15 weeks (From January, 2018 to April,2018) Lesson Plan Name of the Faculty Discipline Semester :Mrs. Reena Rani : Computer Engineering : IV Subject: OBJECT ORIENTED PROGRAMMING USING C++ Lesson Plan Duration :15 weeks (From January, 2018 to April,2018)

More information

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

University of Technology. Laser & Optoelectronics Engineering Department. C++ Lab. University of Technology Laser & Optoelectronics Engineering Department C++ Lab. Second week Variables Data Types. The usefulness of the "Hello World" programs shown in the previous section is quite questionable.

More information

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

MaanavaN.Com CS1203 OBJECT ORIENTED PROGRAMMING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING SUB CODE / SUBJECT: CS1203 / Object oriented programming YEAR / SEM: II / III QUESTION BANK UNIT I FUNDAMENTALS PART-A (2 MARKS) 1. What is Object Oriented

More information

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

Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS Contents Preface... (vii) CHAPTER 1 INTRODUCTION TO COMPUTERS 1.1. INTRODUCTION TO COMPUTERS... 1 1.2. HISTORY OF C & C++... 3 1.3. DESIGN, DEVELOPMENT AND EXECUTION OF A PROGRAM... 3 1.4 TESTING OF PROGRAMS...

More information

Object Oriented Programming

Object Oriented Programming Object Oriented Programming Course Title: Object Oriented Programming Full Marks: 60 20 20 Course No: CSC161 Pass Marks: 24 8 8 Nature of Course: Theory Lab Credit Hrs: 3 Semester: II Course Description:

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

Data Abstraction. Hwansoo Han

Data Abstraction. Hwansoo Han Data Abstraction Hwansoo Han Data Abstraction Data abstraction s roots can be found in Simula67 An abstract data type (ADT) is defined In terms of the operations that it supports (i.e., that can be performed

More information

Object-Oriented Programming

Object-Oriented Programming - oriented - iuliana@cs.ubbcluj.ro Babes-Bolyai University 2018 1 / 56 Overview - oriented 1 2 -oriented 3 4 5 6 7 8 Static and friend elements 9 Summary 2 / 56 I - oriented was initially created by Bjarne

More information

Introduction to Programming

Introduction to Programming Introduction to Programming session 6 Instructor: Reza Entezari-Maleki Email: entezari@ce.sharif.edu 1 Spring 2011 These slides are created using Deitel s slides Sharif University of Technology Outlines

More information

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

A A B U n i v e r s i t y A A B U n i v e r s i t y Faculty of Computer Sciences O b j e c t O r i e n t e d P r o g r a m m i n g Week 4: Introduction to Classes and Objects Asst. Prof. Dr. M entor Hamiti mentor.hamiti@universitetiaab.com

More information

1: Introduction to Object (1)

1: Introduction to Object (1) 1: Introduction to Object (1) 김동원 2003.01.20 Overview (1) The progress of abstraction Smalltalk Class & Object Interface The hidden implementation Reusing the implementation Inheritance: Reusing the interface

More information

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

Lecture 7. Log into Linux New documents posted to course webpage Lecture 7 Log into Linux New documents posted to course webpage Coding style guideline; part of project grade is following this Homework 4, due on Monday; this is a written assignment Project 1, due next

More information

CS201 Some Important Definitions

CS201 Some Important Definitions CS201 Some Important Definitions For Viva Preparation 1. What is a program? A program is a precise sequence of steps to solve a particular problem. 2. What is a class? We write a C++ program using data

More information

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

OBJECT ORIENTED PROGRAMMING. Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PROGRAMMING Ms. Ajeta Nandal C.R.Polytechnic,Rohtak OBJECT ORIENTED PARADIGM Object 2 Object 1 Data Data Function Function Object 3 Data Function 2 WHAT IS A MODEL? A model is an abstraction

More information

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

COMP322 - Introduction to C++ Lecture 02 - Basics of C++ COMP322 - Introduction to C++ Lecture 02 - Basics of C++ School of Computer Science 16 January 2012 C++ basics - Arithmetic operators Where possible, C++ will automatically convert among the basic types.

More information

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

CONTENTS. PART 1 Structured Programming 1. 1 Getting started 3. 2 Basic programming elements 17 List of Programs xxv List of Figures xxix List of Tables xxxiii Preface to second version xxxv PART 1 Structured Programming 1 1 Getting started 3 1.1 Programming 3 1.2 Editing source code 5 Source code

More information