why calling funk(&a) gives compile error
func(int * & data) {data++;} int main(){ int = 5; int *p = &a; func(&a); //this gives compile error funk(p); //this works fine }
error: invalid initialization of non-const reference of type ‘int*&’ rvalue of type ‘int*’
just error message explains, parameter needs reference variable, , &a
not variable, it's an address of variable.
Comments
Post a Comment