STARTING OUT WITH C++ MPL
9th Edition
ISBN: 9780136673989
Author: GADDIS
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Concept explainers
Question
Chapter 10, Problem 10PC
Program Plan Intro
Square
Program Plan:
- Include the required header files.
- Define the class “Squares”.
- Define the necessary function and variables.
- Define the constructor to initialize the required variables and methods.
- Use smart pointer to manage the objects of the class.
- Display the size of the object that is created.
- Display the value of square using the function “print()”.
- Destructor function displays the reallocated size.
- Define the main () function.
- Declare and define the necessary variables.
- Use special pointer to allocate the memory of the class.
- Call the function “outputSquares()” to display the square of numbers.
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
dangling and wild pointers are known to be problems with pointers.justify the statement with the help of suitable examples.
Define arrays versus pointers.
Show (in code) the 4 ways you can initialize a pointer (depending on what you want to allow to change). In each example, explain what can change and what can not.
Chapter 10 Solutions
STARTING OUT WITH C++ MPL
Ch. 10.5 - Prob. 10.1CPCh. 10.5 - Write a statement defining a variable dPtr. The...Ch. 10.5 - List three uses of the symbol in C++.Ch. 10.5 - What is the output of the following program?...Ch. 10.5 - Rewrite the following loop so it uses pointer...Ch. 10.5 - Prob. 10.6CPCh. 10.5 - Assume pint is a pointer variable. For each of the...Ch. 10.5 - For each of the following variable definitions,...Ch. 10.10 - Assuming array is an array of ints, which of the...Ch. 10.10 - Give an example of the proper way to call the...
Ch. 10.10 - Complete the following program skeleton. When...Ch. 10.10 - Look at the following array definition: const int...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Assume ip is a pointer to an int. Write a...Ch. 10.10 - Prob. 10.15CPCh. 10.10 - Prob. 10.16CPCh. 10.10 - Prob. 10.17CPCh. 10.12 - Prob. 10.18CPCh. 10.12 - Assume the following structure declaration exists...Ch. 10.12 - Prob. 10.20CPCh. 10 - Each byte in memory is assigned a unique _____Ch. 10 - The _____ operator can be used to determine a...Ch. 10 - Prob. 3RQECh. 10 - The _____ operator can be used to work with the...Ch. 10 - Prob. 5RQECh. 10 - Creating variables while a program is running is...Ch. 10 - Prob. 7RQECh. 10 - If the new operator cannot allocate the amount of...Ch. 10 - Prob. 9RQECh. 10 - When a program is finished with a chunk of...Ch. 10 - You should only use the delete operator to...Ch. 10 - What does the indirection operator do?Ch. 10 - Look at the following code. int X = 7; int ptr =...Ch. 10 - Name two different uses for the C++ operator.Ch. 10 - Prob. 15RQECh. 10 - Prob. 16RQECh. 10 - Prob. 17RQECh. 10 - What is the purpose of the new operator?Ch. 10 - What happens when a program uses the new operator...Ch. 10 - Prob. 20RQECh. 10 - Prob. 21RQECh. 10 - Prob. 22RQECh. 10 - Prob. 23RQECh. 10 - Prob. 24RQECh. 10 - Prob. 25RQECh. 10 - Prob. 26RQECh. 10 - What happens when a unique_ptr that is managing an...Ch. 10 - What does the get ( ) method of the unique_ptr...Ch. 10 - Prob. 29RQECh. 10 - Prob. 30RQECh. 10 - Prob. 31RQECh. 10 - Prob. 32RQECh. 10 - Consider the function void change(int p) { P = 20;...Ch. 10 - Prob. 34RQECh. 10 - Write a function whose prototype is void...Ch. 10 - Write a function void switchEnds(int array, int...Ch. 10 - Given the variable initializations int a[5] = {0,...Ch. 10 - Each of the following declarations and program...Ch. 10 - Prob. 39RQECh. 10 - Test Scores #1 Write a program that dynamically...Ch. 10 - Test Scores #2 Modify the program of Programming...Ch. 10 - Indirect Sorting Through Pointers #1 Consider a...Ch. 10 - Indirect Sorting Through Pointers #2 Write a...Ch. 10 - Pie a la Mode In statistics the mode of a set of...Ch. 10 - Median Function In statistics the median of a set...Ch. 10 - Movie Statistics Write a program that can be used...Ch. 10 - Days in Current Month Write a program that can...Ch. 10 - Age Write a program that asks for the users name...Ch. 10 - Prob. 10PC
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
- Questlon 1: Write a C program that do the following: write a recursive function that receives a character pointer and replace each 'a' with 'u'. • in the main function define a character array and ask the user to input a word and save it in the array. Call the function. Print the array. Sample input/output: Please enter a word: Safaa After replace: Sufuuarrow_forwardWhat do you understand by dangling and wild pointers? How they are known to be problems with pointers? Explain with the help of example.arrow_forwardWould it be possible to use unique, shared or weak pointers in the code?arrow_forward
- The occurrence of the pointer vanishing when it is rapidly moved is commonly referred to as submarining.arrow_forwardPlease Help Language C++ Write a C++ Program to Multiply Two Matrix Using Multi-Dimensional Arrays. This program takes two matrices of order r1*c1 and r2*c2 respectively. Then, the program multiplies these two matrices (if possible) and displays it on the screen. Note: the use of pointers is not allowed and everything needs to be done in the main() function.arrow_forwardHow do smart pointers work? What function do they fulfil?arrow_forward
- Analyze the pros and cons of using C's pointers and arrays interchangeably.arrow_forwardIt's well knowledge that "dangling and wild pointers" are problematic for pointers. Use specific examples to back up your argument.arrow_forwardThe definition of a pointer variable is exactly the same as its name. What is the function of it? What does it imply exactly to have something called a "dynamic array"? What kind of connection exists between pointers and dynamic arrays?arrow_forward
- In C++ Create an array of head pointers, statically allocated of size 101 of that type: Now, create a pointer that can point to the first element: Show how to dynamically allocate an array of 101 elements of head pointers: Write the code to initialize each element to NULL: Rewrite the code to initialize each element to NULL using pointer arithmetic:arrow_forwardWrite a c++ program to print the elements of an array in the reverse order using pointers. Use user defined function getArray() to read the elements from the user and ReverseArray() to print the elements in the reverse order. CA Microsoft Visual Studio Debug Console Enter the number of elements in the array (max15)10 Enter the elements of the array 1 9 10 The reverse order of elements is 10 9 8 7 6 5 4 3 2 1 C: \Users\1.murugan\source\repos\Project5\x64\Debug\Project5.exe (process 7196) To automatically close the console when debugging stops, enable Tools->0ptions le when debugging stops. Press any key to close this window. ..arrow_forwardSolve the picturearrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage LearningC++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrSystems ArchitectureComputer ScienceISBN:9781305080195Author:Stephen D. BurdPublisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Systems Architecture
Computer Science
ISBN:9781305080195
Author:Stephen D. Burd
Publisher:Cengage Learning