Custom Node Pins

Is there a way to test if a pin has a connection to it using c++? Example:

void TestFunction(int a, int& b)

//if connected
b = a;

//not connected 

b = 5;


I could use if(a == 0) {} but a could possibly have a valid value of 0 and I wouldn’t want it changed if the pin is connected to something passing it 0.