This is an example of a function taking const char * &
as a parameter.
#include <iostream>
using namespace std;
char test[] = "Test";
void func(const char * & str)
{
str = &test[0];
}
int main() {
const char * mytest;
func(mytest);
cout << mytest << endl;
return 0;
}
Why does this work? (http://ideone.com/7NwmYd)
What const
means here? Why func()
can change str
given to this function?
Upd. It's a newbie question, please not minus it.