C++

Asked • 07/29/19

Pointer vs. Reference?

What would be better practice when giving a function the original variable to work with: unsigned long x = 4; void func1(unsigned long& val) { val = 5; } func1(x); or: void func2(unsigned long* val) { *val = 5; } func2(&x); IOW: Is there any reason to pick one over another?

1 Expert Answer

By:

Sasi T. answered • 07/30/19

Tutor
New to Wyzant

I love to learn and spread knowledge!

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.