c++ - 将参数传递给 c++ 11 中的结构
问题描述
一个新手问题,但是如何在 c++ 11 中将参数传递给 struct。我一直在使用 c++ 14 这个方法有效。今天我被迫使用 c++ 11,我被这个错误困住了;
error: no matching function for call to 'infinity::infinity(<brace-enclosed
initializer list>)'return infinity{(x1 == x2), s};
我的代码:
struct infinity{
bool yes = false;
float m = 0;
};
infinity slope(float x1, float y1, float x2, float y2){
float s = (y2-y1)/(x2-x1);
return infinity{(x1 == x2), s};
}
谢谢!
解决方案
推荐阅读
- javascript - 棘手的正则表达式问题?我该怎么做?
- algorithm - 在位串中找到“适合”位模式的更好算法
- javascript - 带有 Ref 的 Mongo 架构:文档未使用保存进行更新
- csv - 表格化文本文件数据
- r - 如何在 R 中按日期和值合并两个 XTS?
- java - 通过 java 类运行时出现 ORA-00936 错误
- python - 计算所需层次结构的数据框中的时间序列数
- debugging - 从 Android Play 商店调试安装的 PWA
- javascript - 如何获取与 iframe 内的元素关联的事件?
- python - 将列表元素从 String 转换为 int