Chat with us, powered by LiveChat c++ - Writemia

c++

Objectives
Review C++ memory management, including copy constructors, destructors, and assignment operators.
Use Valgrind to check for memory leaks.
Review the procedures to access the GL servers and to compile programs on GL.
To ensure that you are able to submit project files on GL.
Introduction
In this project, you will complete a C++ class by writing a copy constructor, destructor, and assginment operator. Furthermore, you will write a test program and use Valgrind to check that your program is free of memory leaks. Finally, you will submit your project files on GL. If you have submitted programs on GL using shared directories (instead of the submit command), then the submission steps should be familiar.

Assignment

 
Step 1: Complete the Stack class
The Stack class implements a templated, linked list-based stack. Complete the class by writing the copy constructor, destructor, and assignment operator. The function prototypes are provided in stack.h. Since the class is templated, the implementation will be done entirely in stack.h; there is no stack.cpp file.

Step 2: Test your code
You must write a test program called mytest.cpp that checks correctness of the copy constructor and assignment operator. See driver.cpp for an example of how to use the stack class; output from the program is provided in driver.txt.

Following is a list of essential tests; we refer to the stack created by the copy constructor or on the left side of the assignment operator as the new stack; the stack from which the copy is made is the source:

Check that a copy is made. The new stack should contain exactly the same data as the source stack.
Check that the copy is deep. Modifying either stack (new or source) should not affect the other.
Check edge cases. For example, do they work correctly if the source stack is empty?
For the assignment operator, check that you have guarded against self-assignment.
Step 5: Check for memory leaks
Run your test programs using Valgrind. For example, assuming you have compiled mytest.cpp, producting the executable mytest.out, run the command

  valgrind mytest.out
If there are no memory leaks, the end of the output should be similar to the following:

  ==8613==
  ==8613== HEAP SUMMARY:
  ==8613==    in use at exit: 0 bytes in 0 blocks
  ==8613==  total heap usage: 14 allocs, 14 frees, 73,888 bytes allocated
  ==8613==
  ==8613== All heap blocks were freed — no leaks are possible
  ==8613==
  ==8613== For lists of detected and suppressed errors, rerun with: -s
  ==8613== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
The important parts are in use at exit: 0 bytes and no leaks are possible. The last line is also important as memory errors can lead to leaks.

Step 7: Submit your files
See the What to Submit section, below.

Implementation Notes
Each project has a section on implementation notes. These point out some issues that you might encounter while developing your code. You should look through the Implementation Notes before you start coding.

The class declarations (Node and Stack) and provided function implementations in stack.h may not be modified in any way. No additional libraries may be used, but additional using statements are permitted.
The locations for the function implementations are clearly marked in stack.h. They must be written at the specified locations; in particular, they must not be written in-line.
Private helper functions may be used, but must be declared in the private section of the Stack class. There is comment indicating where private helper fuction declarations should be written.
You should read through the coding standards for this class.
What to Submit

You must submit the following files to the proj0 submit directory:

stack.h
mytest.cpp

Do you need an answer to this or any other questions?

About Writemia

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Place Order” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order