Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

char**& argument confusion

void func(char**& arg1);

int main() {
  char* container[3] = { "First", "Second", "Third" };
  char** pCon = &container[0];

  func(pCon);            // This works
  func(&container[0]);   // no known conversion from char** to char**&
}

I am clearly missing something here. My logic says that these two should be the same thing.

like image 682
Andres Traumann Avatar asked Aug 25 '13 20:08

Andres Traumann


1 Answers

You cannot bind a non-const reference to a temporary, e.g., you cannot bind a temporary obtained from the address-of operator to a non-const reference.

like image 110
Dietmar Kühl Avatar answered Sep 28 '22 04:09

Dietmar Kühl