没有匹配函数来调用 std::vector<float>
No matching function to call to std::vector<float>
我正在编写一个从3D世界到2D投影的代码,当我试图推回矢量中的坐标时,它给了我一个错误,即没有匹配函数可以调用std::vector。
#include <X11/Xlib.h>
#include "draw.h"
#include "points.h"
#include "unistd.h"
#include <math.h>
#include <vector>
void draw(Display* d, Window w, GC gc)
{
std::vector<float> xpoints;
xpoints.push_back (-1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0);
std::vector<float> ypoints;
ypoints.push_back (1.0, 1.0, 1.0, 1.0, -1.0, -1.0, -1.0, -1.0);
std::vector<float> zpoints;
zpoints.push_back (-1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0, -1.0);
for (;;)
{
XClearWindow(d, w);
for (unsigned int c = 0; c < xpoints.size(); c++)
{
XDrawLine(d, w, gc, xpoints.at(c), ypoints.at(c), xpoints.at(c+1), ypoints.at(c+1));
}
XFlush(d);
usleep(16666);
}
}
不能使用push_back
:同时推送多个值
xpoints.push_back (-1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0);
如果您使用c++11
,您应该直接初始化您的矢量:
std::vector<float> xpoints{-1.0, -1.0, 1.0, 1.0, -1.0, -1.0, 1.0, 1.0};
只需包含向量头:
#include <vector>
相关文章:
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- 在c++中用vector填充一个简单的动态数组
- vector.resize()中的分配错误
- 使用std::vector的OpenCL矩阵乘法
- POCO::PostgreSQL:如何将std::vector支持添加到`Binder::bind`
- 在某些循环内使用vector.push_back时出现分段错误
- 当vector是tje全局变量时,c++中vector的内存管理
- std::vector的包装器,使数组的结构看起来像结构的数组
- 为什么(-1)%vector::size()总是返回0
- 在C++中将类(带有Vector成员)保存为二进制文件
- 编译器如何区分std::vector的构造函数
- 将 int 数组转换为 std::vector<int*>
- 使用 pqxx 将 std::vector 存储在 postgresql 中,并从数据库中检索它
- EASTL矢量<向量<int>>连续的
- 在std::vector上存储带有模板的类实例
- C - 创建矢量&lt; vector&lt; double&gt;&gt;矩阵具有分配而不是inizializ
- std::vector<;uint8_t>;当C++11/14启用时,手动复制而不是调用memcpy
- 使用 std::vector<boost::shared_ptr<Base_Class>> 或 boost::p tr_vector 的性能注意事项是什么<Base>
- 将矩阵"shared_ptr<vector<vector>sp"的行"(*sp)[i]"<T>传递给接受"shared_ptr<vector<T>>
- 如何获取std::vector<DMatch>