Starting Out with C++: Early Objects (9th Edition)
9th Edition
ISBN: 9780134400242
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
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
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.
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: Sufuu
Chapter 10 Solutions
Starting Out with C++: Early Objects (9th Edition)
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
- 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_forwardc++ make a simple prrogram that takes random 2d array entered by user and organizes it use pointers for example if the user enter ((8,4),(3,4),(7,2),(8,6),(3,1)) no limit to number of sets use pointers there should be a function called transformer that will transform them into the right order and a funtion called display that will display what was inputed then it would organize it into ((4,8),(3,4),(2,7),(6,8),(1,3)) IT should only modify it and not make a copy of it.arrow_forward
- Solve the picturearrow_forwardC program Andrew practices programming a lot and recently he came across the topic of pointers. He wondered if he could use pointers to print all prime numbers from an array? Could you help him by writing a C program which takes input in an array and uses a pointer to find and print all the prime numbers from the array. Sample Run: Input: 1 2 3 4 5 Output: 2 3 5arrow_forwardWhat is a variable pointer? What follows? It is a variable array. Why are pointers and dynamic arrays problematic?arrow_forward
- what is the difference between void type pointer amd simple pointer?arrow_forwardHand written answer plzzarrow_forwardIN C PROGRAMMING LANGUAGE: Please write a pointer version of strncpy() named pstr_ncpy(char *dest, char *src, int n) which copies n characters from src and copies them into dest.arrow_forward
- Write a C++ program that determines if an integer array is a palindrome. Declare two pointers to the aray. One pointer points to the starting of the array, another points to the end of the array. Using these pointers determine whether the array is a palindrome. Increment the pointer, which points to the starting of the array, and decrement the pointer which points to the end of the array. The program should ask the user to enter the array size, and then creates an integer array dynamically using the entered size. The user is then asked to fill the array, which is then checked as mentioned earlier. Remember-to delete the dynamic array before exiting the program.arrow_forwardPlease include your code with pointers!!!!arrow_forwardUsing C language and using pointersarrow_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