I'm an old C programmer trying to learn C++, and I was used to the old C style of passing by reference using *. I actually like the C++ syntax much better, it's so much cleaner, but if I use the old C style is that severely frowned upon in C++ circles?
#include <stdio.h>
void swapnum(int *i, int *j) {
int temp = *i;
*i = *j;
*j = temp;
}
void swapnumCPP(int& i, int& j) {
int temp = i;
i = j;
j = temp;
}
int main(void) {
int a = 10;
int b = 20;
printf("before swap: A is %d and B is %d\n", a, b);
swapnum(&a, &b);
printf("after swap: A is %d and B is %d\n", a, b);
printf("before swapCPP: A is %d and B is %d\n", a, b);
swapnumCPP(a, b);
printf("after swapCPP: A is %d and B is %d\n", a, b);
return 0;
}