I tried my best in order to comment the code. I now appreciate if someone can correct my mistakes. There were a few lines that I really don't know what is happening. Why is increase and data have a void datatype and not an int for char for example? It gets confusing at times.

12345678910111213141516171819202122232425262728

// increaser#include <iostream> // input / output stream from keyboardusingnamespace std; // using the standard namespacevoid increase (void* data, int psize) { // creating an increase function with no return data hence void.// we declare two local variables void* data where a pointer is ponting to the varaible data and we created another variable declaring it as int psizeif ( psize == sizeof(char) ) // if condition checks whether psize is equal to the size of the char data type (which is 1 byte)
{ char* pchar; pchar=(char*)data; ++(*pchar); } THIS IS THE LINE WHICH I DON'T REALLY UNDERSTAND!
// if condition evaluates to true, the char variable points to pchar variable where we get the value stored of the varaible, pchar variable is equal to what is stored in char, add to what is stored in the pchar variable
else if (psize == sizeof(int) ) // if the first if isn't evaluated to true, it checks the condition and see whether psize is equal to the size of int in bytes (which I assume is 4 bytes)
{ int* pint; pint=(int*)data; ++(*pint); } THIS IS THE LINE WHICH I DON'T REALLY UNDERSTAND!
// if condition evaluates to true, the int varaile points to pint varable where we get the value stored of the varaible, pint variable is equal to what is stored in data, add to what is stored in the pint variable
}
int main () { // program execution starts from here
char a = 'x'; // we declare a character a and assign x to it in memory
int b = 1602; // variable b is stored as an integer in memory and is assigned the value 1602
increase (&a,sizeof(a)); // HERE, I DON'T UNDERSTAND THIS LINE EITHER.
increase (&b,sizeof(b)); // HERE, I DON'T UNDERSTAND THIS LINE EITHER.
cout << a << ", " << b << endl; // output the values stored in variables a and b to screenreturn 0; // exit code

The first line is an if statement which compares the psize variable (which is passed as an argument to the function) and the size in bytes of the char integral type, which we can safely assume to be 1 byte.

If the condition is met (that psize is equivalent to the size in bytes of a char), execution continues in the branch.

The second line instantiates a character pointer with the name pchar.

The third line initializes pchar to point to data which was passed as an arguement.

The fourth line increments the value of what pchar is pointing to by 1.