Could someone explain to me (in layman's terms please) when to use pointers, pass by reference, this pointer and friendly functions. I understand the concepts but I can't think on my own when to use them. Can someone explain? thanks.

Recommended Answers

All 3 Replies

The reasons will come with increased usage and eduction.

Yes I'm sure BUT I have an exam tomorrow and my professor want us to implement the friends function into a program he's gona have us write and I think my mind is gona go blank :/

You would use pointers or references for two reasons: 1. You want to modify the actual parameter inside the function. 2. You want to avoid pass by copy to conserve resources when passing something big. If you are doing it for the second reason and not the first, then pass by reference-to-const or pointer-to-const.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.