Given the structure below:-
By reference:-Code:typedef struct { int a; word b; } process;
By pointer:-Code:main() { process work; /* init structure variable */ ... do_something( &work ); ... }
Which would be an optimal performance approach if I want to pass a structure into a function?Code:main() { process work; process *ptr_work = &work; /* init structure variable */ ... do_something( ptr_work ); ... }
Also, some reading up here and there came across to a site that says "by reference" is a C++ solution (see http://cplus.about.com/od/cprogrammi.../aa010402a.htm ). I have this impression that it is available in C as well, so the other question I have is if it is really a C++ approach, does that mean most, if not all, C compilers would give me error if I use by reference method?



LinkBack URL
About LinkBacks



