One function is pass by pointer which stores the reference, the other is just pass by a reference... are theses methods equvilent or does one method require more memory than the other?
#include <iostream>
using namespace std;
void cubeByRef(int *num);
void cubeByRef2(int &num);
int main(){
int a = 2;
cubeByRef(&a);
cout << "cubeByRef : " << a << endl;
a = 2;
cubeByRef2(a);
cout << "cubeByRef2: " << a << endl;
return 0;
}
void cubeByRef(int *num){
*num = *num * *num * *num;
}
void cubeByRef2(int &num){
num = num * num * num;
}