Call by reference using pointers.

Hi guys,
I was wondering, what is the difference in practice between a "normal" call by reference and a call by reference made using pointers as arguments? Why one of the two should be prefered over the other? Thank you.
Last edited on
References ensure that the parameter is valid. Pointers allow passing null parameters.
Also, a function that takes a const T & can take the return value of a function call as a parameter without making a copy. For example:
1
2
3
4
5
6
7
8
9
std::string f(){
    return "string";
}

void g(const std::string &s){
    std::cout <<s;
}
//...
g(f());
Topic archived. No new replies allowed.