cannot convert * to **
时间: 2023-09-06 19:07:19 浏览: 43
To convert a pointer to a pointer to a pointer (i.e., `*`) to a pointer to a pointer (i.e., `**`), you can use the address-of operator (`&`). Here's an example:
```c++
#include <iostream>
int main() {
int value = 42;
int* ptr = &value; // pointer to an int
int** ptrToPtr = &ptr; // pointer to a pointer to an int
std::cout << "Value: " << value << std::endl;
std::cout << "Pointer: " << *ptr << std::endl;
std::cout << "Pointer to Pointer: " << **ptrToPtr << std::endl;
return 0;
}
```
In this example, `ptrToPtr` is a pointer to a pointer to an `int`. By using the address-of operator, we assign the address of `ptr` to `ptrToPtr`. Finally, by using the dereference operator (`*`), we can access the value pointed to by `ptr` and `**ptrToPtr`.