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
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
Get step-by-step solutions from verified subject matter experts
