Concept explainers
Write a remove member function that accepts an argument for a number of units and removes that number of units of an item from inventory. If the operation is completed successfully it should return the number of units remaining in stock for that item. However, if the number of units passed to the function is less than the number of units in stock, it should not make the removal and should return - 1 as an error signal.
Want to see the full answer?
Check out a sample textbook solutionChapter 7 Solutions
Starting Out With C++: Early Objects (10th Edition)
Additional Engineering Textbook Solutions
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Starting Out with C++ from Control Structures to Objects (9th Edition)
Database Concepts (7th Edition)
Computer Science: An Overview (12th Edition)
Software Engineering (10th Edition)
Starting Out with Programming Logic and Design (4th Edition)
- In C++ Write the definition of a void function that has two parameters: an array, and an integer parameter that specifies the number of elements in the array. The functions swaps the first and last elements of the array.arrow_forwardTRUE OR FALSE: In C++, comments that begin with the "multi-line" comment symbol can't be nested. A member function of a class has access to only the public data members of the class. If a C++ function does not take any parameters, parenthesis around the empty parameter list are still required. The size of a pointer variable depends on the type that it is pointing to.arrow_forwardplease explain whyarrow_forward
- C++ Write a function named “createPayStub” that accepts the number of hours(integer), and the hourly payrate (double). It will return the pointer to a newlycreated PayStub object. If the given hours or payrate is negative, it will returnnullptr. In addition, it also returns the total payout amount to the caller (in theoutput parameter).Please show how this function is called and returning the proper information.arrow_forwardComputer Science Create a class that will store a list of names. Your class needs to include a function that will return the name that appears first aphabetically, and another function that should return the name that appears last alphabetically. You also need to include a function that will sort the list alphabetically. The class does not need to be case insensitive.arrow_forward// This program reads floating point data from a data file and places those // values into the private data member called values (a floating point array) // of the FloatList class. Those values are then printed to the screen.// The input is done by a member function called GetList. The output// is done by a member function called PrintList. The amount of data read in // is stored in the private data member called length. The member function// GetList is called first so that length can be initialized to zero.#include <iostream>#include <fstream>#include <iomanip> using namespace std;const int MAX_LENGTH = 50; // MAX_LENGTH contains the maximum length of our list class FloatList // Declares a class that contains an array of// floating point numbers{ public:void getList(ifstream&); // Member function that gets data from a file void printList() const;// Member function that prints data from that // file to the screen.FloatList();// constructor that sets length to…arrow_forward
- When the following program is executed, it terminates with an error. Which option best describes the cause of this error? Question options: The function will terminate the program due to the recursive limit being reached. The function will terminate the program due to a type mismatch when evaluating an operator. The function will terminate the program due to invalid syntax. The function will terminate the program due to an invalid type conversion. The function will terminate the program due to it accessing an invalid list index. None of these optionsarrow_forwardc++ Write a class named TestScores. The class constructor should accept an array of test scores as itsargument. The class should have a member function that returns the average of the test scores. If any testscore in an array is negative or greater than 100 it should display a message.arrow_forwardTo call the read member function, what are the two parameters that must be supplied?arrow_forward
- When defining an array of a classtype, a C++ programmer has no way to specify which overloaded constructor is used on each declared array element, as the default no-argument constructor will always be used no matter what. True O Falsearrow_forwardFor a non-constant member function of class Test, the this pointer has type: Select one: O a. const Test * const O b. Test * const O . Test const * O d. const Test *arrow_forwardC++ Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has setter and getter functions for both length and width. The program should ASK THE USER TO INPUT length and width value. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. A sample output of your program should look like follows: length = 1.0; width = 1.0; perimeter = 4.0; area = 1.0 another example: length = 5.0; width = 4.0; perimeter = 18.0; area = 20.0 There should be three files and ONE class only. .h file contains class definition, .cpp file contains the implementation of the class in .h file and main.cpp should contain the driver code.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage LearningEBK JAVA PROGRAMMINGComputer ScienceISBN:9781337671385Author:FARRELLPublisher:CENGAGE LEARNING - CONSIGNMENT