Declare and Dereference a Pointer

Given an integer a and a pointer p (initially storing null value), store its address in a pointer p and print the value using pointer dereferencing.

Example 1:

Input: a = 10

Output: 10

Example 2:

Input: a = 5

Output: 5

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

Hints

0
class Solution {
public:
void assignPointer(int &a, int *&p) {
//your code goes here
}
};
Test Case

Input:

A