c++ - 为什么我必须在这种情况下参考?
问题描述
int main(){
while(true){
char input = getchar();
int x, y;
POINT xypos;
if (input == 'S' || input == 's'){
std::cout <<"enter new position" << std::endl;
std::cin >> x >> y;
SetCursorPos(x, y);
} else if (input == 'g' || input == 'G'){
GetCursorPos(&xypos);
std::cout << "X: " << xypos.x << "Y " << xypos.y << std::endl;
}
}
return 0;
}
有人可以解释一下为什么GetCursorPos
它必须在参数中引用 xypos 对象吗?为什么不能直接使用呢?谢谢
解决方案
您可能的意思是为什么GetCursorPos
(来自 WinAPI)不只是返回位置而不是获取指针并填充它?
这就是 WinAPI 的工作方式,几乎所有函数都返回BOOL
以指示成功或失败,并获取它们通过指针填充的信息。
推荐阅读
- json - DotNet 5.0 Core MVC - 与 JsonPatchDocument 一起使用 - PATCH 不起作用 - 找不到 404
- java - 上传一组 .png 文件并保存到 HashMap
- flutter - Flutter(dart)文件上传,进度条-文件上传流在上传过程中不回馈数据
- airflow - 任务缺少 start_date 参数
- python - 如何在 v.DataTable 中选择一个元素?
- javascript - jQuery mobile 只使用一个 Event
- jquery - jQuery UI(可拖动):放置后元素未放置在我的光标位置
- reactjs - 警告:无效的 DOM 属性“类”。你的意思是“className”吗?
- android - Firebase onCall 函数将结果保存到 android 中的变量中
- mapr - 带有 mapr 客户端的节点是否需要访问我要使用 distcp 复制的文件?