cplusplus
.com
TUTORIALS
REFERENCE
ARTICLES
FORUM
C++
Tutorials
Reference
Articles
Forum
Forum
Beginners
Windows Programming
UNIX/Linux Programming
General C++ Programming
Lounge
Jobs
Forum
Beginners
how are these functions different?
how are these functions different?
Oct 30, 2011 at 9:43pm UTC
targt123
(30)
void f1(int & k)
{ k = k + 1;}
void f2(int * k)
{ (*k) = (*k) + 1; }
void f3(int * & k)
{ (*k) = (*k) + 1; }
They all do the same thing. From compiler point of view, how are f1, f2, f3 different? They all take a reference and change the value stored in it.
When would one be preferred over the other?
Topic archived. No new replies allowed.