Question: Complete the PigNode class destructor. The destructor prints Deallocating PigNode (, followed by the value of piglets, then ). End with a newline. Ex: If

Complete the PigNode class destructor. The destructor prints "Deallocating PigNode (", followed by the value of piglets, then ")". End with a newline.

Ex: If the input is 12, then the output is:

Deallocating PigNode (12)

#include using namespace std;

class PigNode { public: PigNode(int pigletsValue); ~PigNode(); int piglets; PigNode* next; };

PigNode::PigNode(int pigletsValue) { piglets = pigletsValue; }

/* Your code goes here */

int main() { PigNode* myPig; int inputValue;

cin >> inputValue;

myPig = new PigNode(inputValue); delete myPig; return 0; }

c++ and please please make it correct

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!