Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
9th Edition
ISBN: 9780133862225
Author: Walter Savitch
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Expert Solution & Answer
Chapter 17.1, Problem 4STE
Program Description Answer
The parameter T is a variable that can be any type, whether built into C++ or defined by the programmer.
Hence, the correct answer is option “D”.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
Which is a proper way to define function template that returns the minimum of the two values of arbitrary type?
Group of answer choices
template <class T>int minimum(int a, int b) { if (a < b) return a; return b; }
template <class T>int minimum(int a, T b) { if (a < b) return a; return b; }
template <class T>int minimum(T a, T b) { if (a < b) return a; return b; }
template <class T>T minimum(T a, T b) { if (a < b) return a; return b; }
Write a program in C++ that reads a list of enrollments from a file and prints a class roster for the teacher. The program would use files, functions, and classes.Here's what the output should look like:
$
./enroll.out
Welcome to the Roster Generator Program!!! Please enter the name of your names file: bob.dat
I'm sorry, I could not open 'bob.dat'.
Please enter another name: csc442
File 'csc442' opened successfully!
Name | Major | Phone # | Town
----------------+--------------------+---------------+-------------------
Jason James | Computer Science | 555/555-1122 | Westfalia, HI 665
Faruk Ahmed | Medeaval French Po | 332-4546 | Slimsville, PQ 22
Sean Ramirez | Underwater Basket | 1-444/411-441 | Fritter, HO 44331
Happy Gilmore | Yellow Tail Migrat | | Simonton, SZ 1124
Total Enrollment: 4
Thank you for using the RGP!!
Endeavor to have a gyroscopic day!
$
I need to know how to do this in python:
The base class Pet has attributes name and age. The derived class Dog inherits attributes from the base class Pet class and includes a breed attribute. Complete the program to:
Create a generic pet, and print the pet's information using print_info().
Create a Dog pet, use print_info() to print the dog's information, and add a statement to print the dog's breed attribute.
Ex: If the input is:
Dobby 2 Kreacher 3 German Schnauzer
the output is:
Pet Information: Name: Dobby Age: 2 Pet Information: Name: Kreacher Age: 3 Breed: German Schnauzer
Chapter 17 Solutions
Problem Solving with C++, Student Value Edition plus MyProgrammingLab with Pearson eText -- Access Card Package (9th Edition)
Ch. 17.1 - Write a function template named maximum. The...Ch. 17.1 - Prob. 2STECh. 17.1 - Define or characterize the template facility for...Ch. 17.1 - Prob. 4STECh. 17.1 - Display 7.10 shows a function called search, which...Ch. 17.1 - Prob. 6STECh. 17.2 - Give the definition for the member function...Ch. 17.2 - Give the definition for the constructor with zero...Ch. 17.2 - Give the definition of a template class called...Ch. 17.2 - Is the following true or false? Friends are used...
Ch. 17 - Write a function template for a function that has...Ch. 17 - Prob. 2PCh. 17 - Prob. 3PCh. 17 - Redo Programming Project 3 in Chapter 7, but this...Ch. 17 - Display 17.3 gives a template function for sorting...Ch. 17 - (This project requires that you know what a stack...Ch. 17 - Prob. 6PPCh. 17 - Prob. 7PPCh. 17 - This project requires that you complete...
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
- What is the output of the following C++ code? #include <iostream> using namespace std; class BaseClass { protected: int i; public: BaseClass(int x) { i = x; } ~BaseClass() { } }; class DerivedClass: public BaseClass { int j; public: DerivedClass(int x, int y): BaseClass(y) { j = x; } ~DerivedClass() { } void show() { cout << i << " " << j << endl; } }; int main() { DerivedClass ob(3, 4); ob.show(); return 0; }arrow_forwardWhich of the following are true about polymorphism? (Multiple choice can be selected) A It means many forms or multiple transformations. B It is the method of recycling a block of code and changing it to another form. C It is the passing of variables to a child dass. D It is the method used for the protection of data E None of the other choices are correctarrow_forwardWhen Is A Template A Better Solution Than A Base Class?arrow_forward
- Put the client program in a separate file from the class, and divide the class into specification file (fraction.h) and implementation file (fraction.cpp), so your code will be in 3 separate files. Fraction.h #include <iostream>using namespace std; int gcd(int a, int b) { if (a == 0) return b; if (b == 0) return a; if (a == b) return a; if (a > b) return gcd(a - b, b); return gcd(a, b - a);} class Fraction {private: // numerator and denominator int n, d; public: // simplifies the fraction void simplify() { int g = gcd(n, d); n /= g; d /= g; } // default constructor Fraction() { n = 0, d = 1; } // parameterised constructor Fraction(int a, int b) { n = a, d = b; simplify(); } // prints the fration as n/d void print() const { cout << n << "/" << d; } // multiplies 2 fractions and returns it Fraction multipliedBy(Fraction f) const { f.simplify(); Fraction r; r.n = n * f.n; r.d = d * f.d; r.simplify(); return r; } // divides two fraction and…arrow_forwardSo that a reference parameter may be supplied, which keyword is used?arrow_forwardAll template definitions begin with the keyword_____,followed by a list of template parameters enclosed in______.arrow_forward
- 1)- What is meant by a dynamic array, and write a line of C++ code to create a dynamic array of 10 doubles. 2)-What is a constructor? 3)-What is meant by the prototype method of software development?arrow_forwardGiven a function template defined as the following: template<class T> T myMax(T x, T y) { return (x > y)? x : y; } Which of the following is the correct code to call this function to compare two string "This" and "That"? Question 1 options: myMax("This", "That"); myMax(<string>"This", <string>"That"); myMax<string>("This", "That"); myMax((string)This, (string)That);arrow_forwardWhat is the difference between template function and template classes elaborate with the help of an example?arrow_forward
- Can someone help me with this c++ code? Criteria: Program executes without crashing Appropriate Internal Documentation Base Animal Class: Correct Private Data Members Constructors function appropriately (correct number of constructors, number of arguments, output of messages, etc.) Correct get and set functions Derived Dog, Rabbit, Fish, and Snake classes Correct Private Data Members Constructors/destructors function appropriately (correct number of constructors, number of arguments, output of messages, etc.) Correct get and set functions Move function implementation Dynamic allocation of animals Random generation of ages and correct seed value Output contains appropriate information Array used to store 5 animals correctly Memory is deallocated appropriatelyarrow_forwardIn this task, we’re going to be simulating an email message. ●Create a class definition for an Email.The initialiser takes in two arguments and stores them as instance-level variables:○from_address - the sender’s email address.○subject_line - the subject of the email.○email_contents-the content of the email.●In addition,the initialiser will create two more instance-level variables with defaultvalues:○has_been_read - initialised to False.○is_spam - initialised to False.●Create a function in this class called mark_as_read which should change has_been_read to true.●Create a function in this class called mark_as_spam which should change is_spam to true.●Create another class called "Inbox" to store all emails (note that you can have a list of objects). The initaliser doesn’t take any arguments, and only initialises an empty list. This list is where all of your Email objects will be stored.●Within the Inbox class, create the following methods:○add_email (self, from_address, subject_line,…arrow_forwardPlease answer in Python In this assignment, you will do an implementation of the Huffman Code. If you have the Data Structures book for this class, on pages 415-421 is the theory for encoding a String using the Huffman Code. There is also a PDF of these pages on the class website. Your task is to develop a proof of concept of the Huffman Code and demonstrate it by taking a String and encoding it. The Huffman Code requires knowledge of a few data structure concepts discussed in class: Priority Queues Binary Trees Recursion Arrays and/or Linked Lists In your program, you will demonstrate an understanding of all these concepts by developing your own priority queue, node, binary tree, array, and/or linked list, and use of recursion to support the Huffman Code encryption algorithm. Read through the theory of the Huffman Code in the text and then write a program that can take a String and encrypt it. For example, given a String “Hello World”, the program should apply the Huffman Code…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 Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning