Take a look at the following and consider whether the function is pure:
void printResults(){
int* pValue = new int(10);
cout << "Address: " << pValue << endl;
cout << "Increment pointer address and value pure:" <<
incrementPointerAddressAndValuePure(pValue) << endl;
cout << "Address after increment: " << pValue << endl;
cout << "Value after increment: " << *pValue << endl;
delete pValue;
}
Well, let's see—it doesn't have arguments, so no value is changed. But something is off when compared to our previous example, that is, it doesn't return values. Instead, it calls a few functions, of which at least one is pure.
So, does it have side effects? Well, yes; one on almost every line of code:
cout <<...