Destructor
You are given an integer a.
You are required to:
- Create a class Student that dynamically allocates memory for an integer pointer ptr
- Assign the value of integer a to the memory pointed by ptr
- Implement a destructor to free the allocated memory using delete
- Create an object of the class and output the value stored at pointer ptr
Note:
- The class name must be exactly Student
- The pointer field name must be exactly ptr and it should be public
Example 1:
Input: a = 34
Output: 34
Example 2:
Input: a = 45
Output: 45
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= a <= 100