69 8 C:\Users\86152\Documents\c语言(1)\通讯录.cpp [Error] cannot convert 'input()::People*' to 'people*' in assignment
时间: 2023-11-23 14:03:16 浏览: 42
这个错误是因为你在将一个 `input()` 函数返回的 `People` 类型指针转换为 `people` 类型指针时出错了。可能是因为你定义 `People` 和 `people` 两个类,它们的类型不一致,导致无法进行转换。
请检查你的代码,确保使用的类型名称是正确的,并且在进行类型转换时需要使用适当的语法。例如,可以使用强制类型转换操作符 `static_cast` 进行类型转换,示例代码如下:
```c++
People* p = input(); // 假设 input() 函数返回 People* 类型指针
people* q = static_cast<people*>(p); // 使用 static_cast 进行类型转换
```
当然,这只是一个示例,具体的实现取决于你的代码结构和要求。希望能帮助到你解决问题。
相关问题
72 9 C:\Users\86152\Documents\c语言(1)\通讯录.cpp [Error] 'string' was not declared in this scope
这个错误提示说明你的代码中使用了 `string` 类型,但是编译器无法识别它。这通常是因为你没有包含 `string` 类型的头文件。
如果你使用的是标准库中的 `string` 类型,那么你需要在代码开头添加以下语句:
```c++
#include <string>
```
如果你使用的是自己定义的 `string` 类型,那么你需要检查一下是否正确地定义了这个类型,并且在使用前进行了声明或者定义。
74 29 C:\Users\86152\Documents\c语言(1)\通讯录.cpp [Error] ISO C++ forbids comparison between pointer and integer [-fpermissive]
这个错误是因为你在代码中进行了指针和整数之间的比较,而C++不允许这样的操作。可能是在if语句或while语句中出现了这样的问题。
解决方法:
1.检查代码中是否有指针和整数之间的比较。
2.如果确实需要进行这样的比较,可以将指针转换为整数类型后再进行比较。
例如:
```c++
if((int)ptr == 10){ //将指针转换为整数
//do something
}
```
3.或者使用指针运算代替指针和整数之间的比较。
例如:
```c++
int* ptr = new int[10];
for(int i=0;i<10;i++){
if(ptr+i == ptr+5){ //使用指针运算
//do something
}
}
```
希望以上解决方法能够帮到你。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![-](https://csdnimg.cn/download_wenku/file_type_column_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)