What does '&' mean in C++? -
what '&' mean in c++? within function
void read_wav::read_wav(const string &filename) { }
and it's equivalent in c?
thanks
edit 1
if want transform above c++ function c function, how it?
in context, & makes variable reference.
usually, when pass variable function, variable copied , function works on copy. when function returns, original variable unchanged. when pass reference, no copy made , changes made function show after function returns.
c doesn't have references, c++ reference functionally same pointer in c. difference pointers have dereferenced when use them:
*filename = "file.wav";
but references can used though original variable:
filename = "file.wav";
ostensibly, references supposed never null, although it's not impossible happen.
the equivalent c function be:
void read_wav(const char* filename) { }
this because c doesn't have string
. usual practice in c send pointer array of characters when need string. in c++, if type string constant
read_wav("file.wav");
the type const char*
.
Comments
Post a Comment