Which defintion is better?

Which way is the fastest defintion?
1
2
3
4
5
6
7
8
9
10
11
12
13
struct aStruct
{
int i;
double d;
};

Func(double d){d = 100;}
Func (double *d){(*d)=100;}
Func (double &d){d = 100;}

Func(aStruct a){a.d = 100;}
Func(aStruct *a){a->d = 100;}
Func(aStruct &a){a.d = 100;}

Thanks!
Last edited on
You should think about correctness before thinking about performance. What do you want the functions to do? I guess you don't want the first version of the functions because that would be a useless function. There is probably no different in speed between the pointer and reference versions. I would have picked the reference version because I think it's nicer and a reference can't be null.
Topic archived. No new replies allowed.