Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 16, Problem 17RQE
The beginning of a template is marked by a(n) __________.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
C++
************Comment code please************
Into two files, p1.h and p1.cpp, create a class called intList with the following members
Private members:
int *a // A pointer to the array into which the list values will be stored.
int capacity; // memorialize the capacity of the list
int size; An integer “pop” to record the number of entries in the list
Public members:
constructor intList(int size) that causes the array to be sized at “size” entries, with a default size of 100
destructor ~intList() that deletes the dynamically allocated array “a”
bool insert(int v) – inserts the value v at the beginning of the list; all other entries shift right. Returns true if v was inserted; otherwise, it returns false.
bool add(int v) – inserts the value v at the end of the list. Returns true if the value was inserted; otherwise, it returns false.
bool insertAt(int v, int index) – inserts the value v at the index “index”; values at that position need to shift right. Returns true if the…
1. Write a function named “getSumBeforeNegative” that takes in a pointer to the array of integers and its size. It will return the sum of all values before it sees a negative number. If there is no negative number in the list, it returns the sum of all numbers in the array.For example,int numList[] = {10,20,-1, 30);// will return 30int priceList[] = {10, 20, 30);// will return 60It must use pointers to integer instead of array index.Write a main program and show how this function is called and used.
1. Write a C++ function named "extractDebugOption" that accepts arguments similar to argc (an integer for the array size) and argv (an array of pointers to C-string). It will determine whether it has the argument of "/debug yes" or "/debug no". It will return true if the debug option is yes. If "/debug no" or there is no debug option or "/debug" without "yes" or "no" followed, it will return false.
Note: command line arguments are simply an array of pointers to C-string.
Please test it with the following command line arguments
These will return true"/debug yes""/compile /debug yes"
These will return false"/debug no""/debug""debug""yes /debug""no /debug"
Chapter 16 Solutions
Starting Out with C++ from Control Structures to Objects (8th Edition)
Ch. 16.1 - Prob. 16.1CPCh. 16.1 - Prob. 16.2CPCh. 16.1 - Prob. 16.3CPCh. 16.1 - Prob. 16.4CPCh. 16.1 - Prob. 16.5CPCh. 16.3 - Prob. 16.6CPCh. 16.3 - The following function accepts an i nt argument...Ch. 16.3 - Prob. 16.8CPCh. 16.3 - Prob. 16.9CPCh. 16.4 - Prob. 16.10CP
Ch. 16.4 - Prob. 16.11CPCh. 16 - Prob. 1RQECh. 16 - Prob. 2RQECh. 16 - Prob. 3RQECh. 16 - Prob. 4RQECh. 16 - What is unwinding the stack?Ch. 16 - What happens if an exception is thrown by a classs...Ch. 16 - How do you prevent a program from halting when the...Ch. 16 - Why is it more convenient to write a function...Ch. 16 - Why must you be careful when writing a function...Ch. 16 - Prob. 10RQECh. 16 - Prob. 11RQECh. 16 - Prob. 12RQECh. 16 - The line containing a throw statement is known as...Ch. 16 - Prob. 14RQECh. 16 - Prob. 15RQECh. 16 - Prob. 16RQECh. 16 - The beginning of a template is marked by a(n)...Ch. 16 - Prob. 18RQECh. 16 - Prob. 19RQECh. 16 - Prob. 20RQECh. 16 - Prob. 21RQECh. 16 - _____________ are pointer-like objects used to...Ch. 16 - Prob. 23RQECh. 16 - Write a function that searches a numeric array for...Ch. 16 - Write a function that dynamically allocates a...Ch. 16 - Make the function you wrote in Question 17 a...Ch. 16 - Write a template for a function that displays the...Ch. 16 - Prob. 28RQECh. 16 - Prob. 29RQECh. 16 - Prob. 30RQECh. 16 - Prob. 31RQECh. 16 - Prob. 32RQECh. 16 - Prob. 33RQECh. 16 - Prob. 34RQECh. 16 - T F All type parameters defined in a function...Ch. 16 - Prob. 36RQECh. 16 - T F A class object passed to a function template...Ch. 16 - Prob. 38RQECh. 16 - Prob. 39RQECh. 16 - Prob. 40RQECh. 16 - Prob. 41RQECh. 16 - T F A class template may not be derived from...Ch. 16 - T F A class template may not be used as a base...Ch. 16 - Prob. 44RQECh. 16 - Prob. 45RQECh. 16 - Prob. 46RQECh. 16 - Prob. 47RQECh. 16 - try { quotient = divide(num1, num2); } cout The...Ch. 16 - template class T T square(T number) { return T T;...Ch. 16 - template class T int square(int number) { return...Ch. 16 - Prob. 51RQECh. 16 - Assume the following definition appears in a...Ch. 16 - Assume the following statement appears in a...Ch. 16 - Prob. 1PCCh. 16 - Prob. 2PCCh. 16 - Prob. 3PCCh. 16 - Prob. 4PCCh. 16 - Prob. 5PCCh. 16 - IntArray Class Exception Chapter 14 presented an...Ch. 16 - TestScores Class Write a class named TestScores....Ch. 16 - Prob. 9PCCh. 16 - SortableVector Class Template Write a class...Ch. 16 - Inheritance Modification Assuming you have...Ch. 16 - Prob. 12PCCh. 16 - Prob. 13PCCh. 16 - 14. Test Scores vector
Modify Programming...Ch. 16 - Prob. 15PCCh. 16 - Prob. 16PCCh. 16 - Prob. 17PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Type in and run the 12 programs presented in this chapter. Compare the output produced by each program with the...
Programming in C
(Population growth) A certain city had a population of 25000 in 1960 and a population of 30,000 in 1970. Assume...
Differential Equations: Computing and Modeling (5th Edition), Edwards, Penney & Calvis
It is not necessary to initialize accumulator variables.
Starting Out with Programming Logic and Design (4th Edition)
Assuming the following enum declaration exists: enum Dog { POODLE, BOXER, TERRIER } what will the following sta...
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Write a declaration of a local variable called cs101 that can hold an ArrayList of Student.
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
List for advantages of SQL-invoked routines.
Modern Database Management (12th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- 1. Write a function called displayCodes to receive the pointer of the first element of the array and the numberof elements in the array.Call the function displayCodes from the main function. 2. Write a function called displayLocations to receive a pointer to the address of the first element of the arrayand the number of elements in the array. Display the number of each item and their location in a morereadable format in columns as shown in the screen shot below.Call the function displayLocations from the main function.arrow_forwardPlease explain DNA Sequencing more clearly for me please there's a picture of the decription and also please comment on each line if possible on the code below to for me to have an understanding of what each line is doing. It is in C++. #include <iostream>#include <string>#include <vector>#include <set> using namespace std; set<string> longestCommonSubstring(const string& a, const string& b) { int maxLen = 0; vector<vector<int> > longestSuffix(a.size(), vector<int>(b.size())); set<string> result; for(int i = 0; i < a.size(); ++i) { for(int j = 0; j < b.size(); ++j) { if (a[i] == b[j]) { int ¤t = longestSuffix[i][j]; current = i == 0 || j == 0 ? 1 : longestSuffix[i - 1][j - 1] + 1; int from = i - current + 1; if (current > maxLen) { result.clear(); result.insert(a.substr(from, current));…arrow_forwardassembly language ctt 9. Counting Nearly Matching ElementsWrite a procedure named CountNearMatches that receives pointers to two arrays of signed doublewords, a parameter that indicates the length of the two arrays, and a parameter that indicates the maximum allowed difference (called diff) between any two matching elements. For each element x(i) in the first array, if the difference between it and the corresponding y(i) in the second array is less than or equal to diff, increment a count. At the end, return a count of the number of nearly matching array elements in EAX. Display this value. Write a test program that calls CountNearMatches and passes pointersto two different pairs of arrays. Use the INVOKE statement to call your procedure and pass stackparameters. Create a PROTO declaration for CountMatches. Save and restore any registers (other than EAX) changed by your procedure.arrow_forward
- CIS 1275 C++ Programming Part I: Planets Extra Credit Using vectors and functions This program goes where no program has gone before, exploring new frontiers in C++. The program performs calculations concerning weight on various planets as well as travel time between planets. This will be a multi-file program consisting of Driver.cpp (main) and functions that will be placed in TravelFunctions.cpp and TravelFunctions.h files. You will use structures to hold Planet and Traveler objects. Use Array’s to store the Planet Objects. There will only be a single Traveler. In main, use Arrays to hold Planet Objects (names, distance from the sun, and the specific gravity on each planet). Create a global constant variable for the number of Planets. Place it in a location that both the TravelFunctions.cpp and Driver.cpp files can get access to it. const int NUM_PLANETS{8}; Your program should first declare variables, instantiate your Array of Planets. Display your course header with the…arrow_forwardOUTPUT MUST MATCH AS IT IS PLEASE. NO COPY PASTE ANSWER ----------------------------- Template Specialization Template Specialization in c++ is used to write generic code. Template code is written once and use for any data type including user-defined data types.Example: sort() can be written and used to sort any data type items. Create a Template code that reads input from the user, user can enter any type of data like integer, double, float.sum() is the template method that can take any two types of data and add it and return the sum of the two numbers.Create a Template Specialization method to add two integer values only.If a specialized version is present, the compiler first checks with the specialized version and then the main template. Sample Input and Output:Enter two integer Numbers: 55Enter two float Numbers: 3.53.1Enter two double Numbers: 3.68.6Sum of two integer Numbers: only integer10Sum of two float Numbers: 6.6Sum of two double Numbers: 12.2arrow_forward10.1 Write a template function that returns the average of all the elements of an array. Thearguments to the function should be the array name and the size of the array (type int). In main (),exercise the function with arrays of type int, long, and double. 10.2 Create a function called amax() that returns the value of the largest element in an array. Thearguments to the function should be the address of the array and its size. Make this function into atemplate so it will work with an array of any numerical type. Write a main () program that appliesthis function to arrays of various types.arrow_forward
- Part 1 Write a C/C++ function that will receive a pointer to the address of the first element of the array. Read the ID numbers contained in idnumbers.txt into the array. Display a message which indicates that data is being read from the file. Return the number of elements saved in the array. Part 2 Write a function that will receive the pointer of the first element of an array, as well as the number of elements in the array. Display the contents of the array. Part 3 Write a function that will receive the pointer of the first element of an array, as well as the number of elements in the array. The function should display the birth date of each person. Assume valid years are from 1921-2020. Tip: The underscore character serves as the first locator character for each ID number, you can use this as a landmark to identify the indexes of each ID number. EXAMPLE OUTPUT List of ID…arrow_forward6. Write a swap function, that swaps the values of two variables in main, but usepointers instead of reference parameters.7. Write a function that takes an array of ints and its size as arguments. It shouldcreate a new array that is the same size as the argument. It should set the values inthe new array by adding 10 to each element in the original array. The functionshould return a pointer to the new array. (Make sure you use dynamic memoryallocation) can i get answers for this two sub parts. thanksarrow_forwardTemplate Specialization in c++ is used to write generic code. Template code is written once and use for any data type including user-defined data types.Example: sort() can be written and used to sort any data type items. Create a Template code that reads input from the user, user can enter any type of data like integer, double, float.sum() is the template method that can take any two types of data and add it and return the sum of the two numbers.Create a Template Specialization method to add two integer values only.If a specialized version is present, the compiler first checks with the specialized version and then the main template. Sample Input and Output:Enter two integer Numbers: 55Enter two float Numbers: 3.53.1Enter two double Numbers: 3.68.6Sum of two integer Numbers: only integer10Sum of two float Numbers: 6.6Sum of two double Numbers: 12.2arrow_forward
- Write a function IsPalindrome() that takes an array of characters called Items and an integer called size as parameters. Thelatter indicates the size of the array. The function returns true if thestring represented by the stored elements in Items is a palindrome andfalse otherwise. As usual, uppercase and lowercase versions of the sameletter are considered to be different characters. please add appropriate comments at the end of each code line thank youarrow_forwardC++ Programming Redesign your class myArray using class templates so that the class can be used in any application that requires arrays to process data. #include <iostream>#include "myArray.h" using namespace std; int main(){myArray list1(5);myArray list2(5); int i; cout << "list1 : ";for (i = 0; i < 5; i++)cout << list1[i] << " ";cout << endl; cout << "Enter 5 integers: ";for (i = 0; i < 5; i++)cin >> list1[i];cout << endl; cout << "After filling list1: "; for (i = 0; i < 5; i++)cout << list1[i] << " ";cout << endl; list2 = list1;cout << "list2 : ";for (i = 0; i < 5; i++)cout << list2[i] << " ";cout << endl; cout << "Enter 3 elements: "; for (i = 0; i < 3; i++)cin >> list1[i];cout << endl; cout << "First three elements of list1: ";for (i = 0; i < 3; i++)cout << list1[i] << " ";cout << endl; myArray list3(-2, 6); cout <<…arrow_forwardC++ Part 1 Write a function that will receive a pointer to the address of the first element of the array. Read the ID numbers contained in idnumbers.txt into the array. Display a message which indicates that data is being read from the file. Return the number of elements saved in the array. Part 2 Write a function that will receive the pointer of the first element of an array, as well as the number of elements in the array. Display the contents of the array. Part 3 Write a function that will receive the pointer of the first element of an array, as well as the number of elements in the array. The function should display the birth date of each person. Assume valid years are from 1921-2020. Tip: The underscore character serves as the first locator character for each ID number, you can use this as a landmark to identify the indexes of each ID number. EXAMPLE OUTPUT List of ID…arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License