在下面的函数中,我想以不明确的方式放置cos数组的100x100值(如数组cos [])。在调用函数时声明向量并声明我
void processing(std::vector<std::array<double, 100 >> & cos, int & index)
{
....
}
如何为矢量做到这一点?
在下面的函数中,我想以不明确的方式放置cos数组的100x100值(如数组cos [])。在调用函数时声明向量并声明我
void processing(std::vector<std::array<double, 100 >> & cos, int & index)
{
....
}
如何为矢量做到这一点?
使用模板:
template <typename T>
void processing(std::vector<T> & cos, int & index)
{
....
}
编辑看到评论后。如果你想只接受任何大小的std::array
, 使用非类型模板参数:
template <std::size_t N>
void processing(std::vector<std::array<double, N>> & cos, int & index)
{
}
你是什么意思?你能尽可能多地填写代码,并给出程序的输入输出示例吗?你卡在哪里? –
该函数的一个输出是100 x 100双精度值的向量。但我不想在开始时指定数值(100X100)。我的问题:如何不在声明中指定该号码? – MelMed
'vector>&cos' –