K
kasthurirangan.balaji
Hi,
Recently i came across a functiion declaration as below
void f(char *&a);
Nowhere i have come across this style. I understand, passing by
reference is always better(to avoid copying), that too added with
const like
void f(const std::string &a); //since it was char *a, i assume it to
be a string
This i came across in the book "Secrets of C++ Masters". Though this
book is old, i just wanted to know what it speaks of. I do not know
whether this is still accepted or was a part of pre-standard c++. I
tried a toy program with a function like this. It did compile fine and
executed successfully. As per the book, this style prevents pointer
copy(address copy) - is that true? atleast in c++. Pls advice.
Thanks,
Balaji.
Recently i came across a functiion declaration as below
void f(char *&a);
Nowhere i have come across this style. I understand, passing by
reference is always better(to avoid copying), that too added with
const like
void f(const std::string &a); //since it was char *a, i assume it to
be a string
This i came across in the book "Secrets of C++ Masters". Though this
book is old, i just wanted to know what it speaks of. I do not know
whether this is still accepted or was a part of pre-standard c++. I
tried a toy program with a function like this. It did compile fine and
executed successfully. As per the book, this style prevents pointer
copy(address copy) - is that true? atleast in c++. Pls advice.
Thanks,
Balaji.