SlideShare uma empresa Scribd logo
1 de 2
SOLUTIONJUG.COM

COMP/220 iLab 5 of 7 - C++ Course

CLICK HERE TO GET THE SOLUTION !!!!!!!!




iLab 5 of 7: Pointers and Pointer Operations
iLAB OVERVIEW
Scenario and Summary
This lab will explore the use of pointers in several ways. Pointers will be used to dynamically allocate
memory for new class objects on demand from the user, and they will be used to access class-
member functions. Pointer arithmetic will be used to access and sort class objects according to
criteria explained in the lab.
Pointers are, essentially, address variables, or variables that hold as their value the address of other
variables. In terms of memory management, they are very powerful devices, and they more closely
and efficiently use the actual internal hardware registers of the microprocessor that the program
operates on.
Pointers also have the requirement that the pointer type must be of the same data type as the
variable, or the data that it points to or holds the address of. The power of pointers also hints at the
potential complexity of their use, which is why this lab is focused almost entirely on several different
aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers.
The Resistor class created in the Week 2 lab will be used as the class that the pointer operations will
be used upon. The lab also requires the use of accessor functions and static data members, which
may need to be added to the Resistor class definition and implementation.
Deliverables
1.         Submit a single Notepad file containing the source code for all the files of the lab to the
Dropbox for Week 5. Your source code should use proper indentation and be error free. Be sure that
your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt.

Each program should include a comment section that includes, at a minimum, your name, the lab
and exercise number, and a description of what the program accomplishes.
2.         Submit a lab report (a Word document) containing the following information to the
Dropbox for Week 5.
o          Include your name and the lab or lab-exercise number.
o          Specification: Include a brief description of what the program accomplishes, including its
input, key processes, and output.
o          Test Plan: Include a brief description of the method you used to confirm that your
program worked properly. If necessary, include a clearly labeled table with test cases, predicted
results, and actual results.
o          Summary and Conclusions: Write a statement summarizing your predicted and actual
output, and identify and explain any differences. For conclusions, write at least one nontrivial
paragraph that explains, in detail, either a significant problem you had and how you solved it or, if
you had no significant problems, something you learned by doing the exercise.
o         A UML diagram: This should show all classes, class members, access specifiers, data
types, and function arguments, along with any and all class-to-class relationships.
o         Answers to Lab Questions: Answer any and all lab questions included in the lab steps.
Each lab exercise should have a separate section in the lab-report document.
Your lab grade will be based upon
1.        the formatting of your source code;
2.        the use of meaningful identifiers;
3.        the extent of internal documentation;
4.        the degree to which an exercises’ specifications are met; and
5.        the completeness of your lab report.

iLAB STEPS
STEP 1: Create a Multifile Project

Create a new multifile project using the Resistor class developed in Week 1, and include a new
main() test function.
STEP 2: Modify the Resistor-Class Definition
1.         Add a static data member of the class Resistor to keep track of the number of Resistor
objects that are dynamically created. This will also be used to limit the number of objects that are
dynamically created to the maximum array size of the pointer array in the test function main().
2.         In the Resistor constructor, use a random-number generator to randomly assign a
nominal resistance value to the object between 1,000 and 10,000 ohms. The resistance values are
not required to be standard resistance values.
STEP 3: Create the Test Function Main() and the Support Function
1.         Create an array of pointers of type Resistor.
2.         Use elements of the pointer array to allow the user to dynamically allocate memory and to
instantiate objects of the Resistor class.
3.         Use the indirect member-selection operator (pointer) in the test routine to access function
members of the Resistor class.
4.         Write a new, nonclass function called in function main() to sort the pointers to the
Resistor objects in order from lowest nominal resistance value to highest, passing a pointer to the
Resistor-object pointer as the only passed data argument.
5.         Display the sorted Resistor objects according to the nominal resistance value, from lowest
to highest.
6.         Within the sorting function, use pointer arithmetic to access the individual Resistor
objects.
7.         Function main() should also ensure that there are no memory leaks when the program
ends.

CLICK HERE TO GET THE SOLUTION !!!!!!!!

Mais conteúdo relacionado

Destaque

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

Comp 220 ilab 5 of 7

  • 1. SOLUTIONJUG.COM COMP/220 iLab 5 of 7 - C++ Course CLICK HERE TO GET THE SOLUTION !!!!!!!! iLab 5 of 7: Pointers and Pointer Operations iLAB OVERVIEW Scenario and Summary This lab will explore the use of pointers in several ways. Pointers will be used to dynamically allocate memory for new class objects on demand from the user, and they will be used to access class- member functions. Pointer arithmetic will be used to access and sort class objects according to criteria explained in the lab. Pointers are, essentially, address variables, or variables that hold as their value the address of other variables. In terms of memory management, they are very powerful devices, and they more closely and efficiently use the actual internal hardware registers of the microprocessor that the program operates on. Pointers also have the requirement that the pointer type must be of the same data type as the variable, or the data that it points to or holds the address of. The power of pointers also hints at the potential complexity of their use, which is why this lab is focused almost entirely on several different aspects and uses of pointers. The lab also introduces pointer arrays and pointers to pointers. The Resistor class created in the Week 2 lab will be used as the class that the pointer operations will be used upon. The lab also requires the use of accessor functions and static data members, which may need to be added to the Resistor class definition and implementation. Deliverables 1. Submit a single Notepad file containing the source code for all the files of the lab to the Dropbox for Week 5. Your source code should use proper indentation and be error free. Be sure that your last name and the lab number are part of the file name: for example, YourLastName_Lab5.txt. Each program should include a comment section that includes, at a minimum, your name, the lab and exercise number, and a description of what the program accomplishes. 2. Submit a lab report (a Word document) containing the following information to the Dropbox for Week 5. o Include your name and the lab or lab-exercise number. o Specification: Include a brief description of what the program accomplishes, including its input, key processes, and output. o Test Plan: Include a brief description of the method you used to confirm that your program worked properly. If necessary, include a clearly labeled table with test cases, predicted results, and actual results. o Summary and Conclusions: Write a statement summarizing your predicted and actual output, and identify and explain any differences. For conclusions, write at least one nontrivial
  • 2. paragraph that explains, in detail, either a significant problem you had and how you solved it or, if you had no significant problems, something you learned by doing the exercise. o A UML diagram: This should show all classes, class members, access specifiers, data types, and function arguments, along with any and all class-to-class relationships. o Answers to Lab Questions: Answer any and all lab questions included in the lab steps. Each lab exercise should have a separate section in the lab-report document. Your lab grade will be based upon 1. the formatting of your source code; 2. the use of meaningful identifiers; 3. the extent of internal documentation; 4. the degree to which an exercises’ specifications are met; and 5. the completeness of your lab report. iLAB STEPS STEP 1: Create a Multifile Project Create a new multifile project using the Resistor class developed in Week 1, and include a new main() test function. STEP 2: Modify the Resistor-Class Definition 1. Add a static data member of the class Resistor to keep track of the number of Resistor objects that are dynamically created. This will also be used to limit the number of objects that are dynamically created to the maximum array size of the pointer array in the test function main(). 2. In the Resistor constructor, use a random-number generator to randomly assign a nominal resistance value to the object between 1,000 and 10,000 ohms. The resistance values are not required to be standard resistance values. STEP 3: Create the Test Function Main() and the Support Function 1. Create an array of pointers of type Resistor. 2. Use elements of the pointer array to allow the user to dynamically allocate memory and to instantiate objects of the Resistor class. 3. Use the indirect member-selection operator (pointer) in the test routine to access function members of the Resistor class. 4. Write a new, nonclass function called in function main() to sort the pointers to the Resistor objects in order from lowest nominal resistance value to highest, passing a pointer to the Resistor-object pointer as the only passed data argument. 5. Display the sorted Resistor objects according to the nominal resistance value, from lowest to highest. 6. Within the sorting function, use pointer arithmetic to access the individual Resistor objects. 7. Function main() should also ensure that there are no memory leaks when the program ends. CLICK HERE TO GET THE SOLUTION !!!!!!!!