C++ 嗨,我只是想知道这个错误是什么意思
“错误C2660:'storeInitialValues':函数不接受1个参数”在我尝试构建时显示在代码日志中。我已经查看了这里发布的一些过去的错误,我认为这可能是某种初始化错误,包括usersize、v、dsize和/或asize。我只想看到storeInitialValues(usersize、v、dsize、asize)的特定调用上的错误;就这样。事先非常感谢C++ 嗨,我只是想知道这个错误是什么意思,c++,visual-c++,C++,Visual C++,“错误C2660:'storeInitialValues':函数不接受1个参数”在我尝试构建时显示在代码日志中。我已经查看了这里发布的一些过去的错误,我认为这可能是某种初始化错误,包括usersize、v、dsize和/或asize。我只想看到storeInitialValues(usersize、v、dsize、asize)的特定调用上的错误;就这样。事先非常感谢 #include <iostream> #include <fstream> #include <s
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <ctime>
#include <cstdlib>
using namespace std;
struct vec
{
};
struct arr
{
};
void fillArray(int A[], int size);
void storeInitialValues(int * & arr, int & asize, int & dsize, vector<int>& v, int & usersize);
int main()
{
int usersize, dsize, asize;
vector <int> v;
int * ptr = new int[10];
cout << "How many values in data structures? Please enter values greater than 20." << endl;
cin >> usersize;
while (usersize < 21)
{
cout << "Error, enter values greater than 20!" << endl;
cin >> usersize;
}
cout << "Alright, here are your numbers: " << endl;
storeInitialValues(usersize, v, dsize, asize);
}
// fillArray stores sequential, unique, integer values into an array and
// then randomizes their order
void fillArray(int A[], int size)
{
srand((int)time(0));
for (int i = 0; i < size; i++)
{
A[i] = i + 1;
}
for (int k = size - 1; k>1; k--)
{
swap(A[k], A[rand() % k]);
}
}
// storeInitialValues calls fillArray to produce an array of unique randomly
// organized values and then inserts those values into a dynamically sized
// array and a vector.
void storeInitialValues(int * & arr, int & asize, int & dsize, vector<int>& v, int usersize)
{
int * temp = new int[usersize]; // temporary array for randomized data
fillArray(temp, usersize); // get data
for (int i = 0; i < usersize; i++) // copy data into the dynamic data structures
{
add(arr, asize, dsize, temp[i]);
v.push_back(temp[i]);
}
delete[] temp; // clean up temporary pointer
temp = NULL;
}
void add(int & usersize, int & arr, int & dsize, int & temp[i])
{
}
void remove()
{
}
#包括
#包括
#包括
#包括
#包括
#包括
使用名称空间std;
结构向量
{
};
结构arr
{
};
void fillArray(int A[],int size);
void storeinitialvalue(int*&arr、int&asize、int&dsize、vector&v、int&usersize);
int main()
{
int usersize、dsize、asize;
向量v;
int*ptr=新的int[10];
cout用户大小;
while(用户大小<21)
{
cout用户大小;
}
cout对storeInitialValues的调用与声明完全不匹配。我认为您可能会因为认为变量的名称很重要而感到困惑。事实并非如此。您必须以正确的顺序传递与函数声明中变量类型匹配的变量,因为名称是不相关的
int*&arr是一个非常奇怪的声明。int*arr将是指向可以作为数组处理的int的指针。使用int*&?mixed*和-,您的目标是什么?需要非常小心地使用。但是您也在使用向量,这是处理数组的一种非常安全的方法。为什么不使用向量呢?您还需要在主函数中声明并分配ptr,但您不使用它,也不删除它。该函数似乎需要5个参数,但您仅使用4个参数调用它。此外,您有vector,但出于一些奇怪的原因,您不将其用于它本应用于的用途。例如int*temp=new int[usersize];
可以简单地替换为std::vector temp(usersize);
storeInitialValues函数接受5个参数,而您只传递了4个参数。而且第一个参数为*的函数定义看起来是错误的。将输入定义为*并传递地址。请在标题上明确说明您的问题所在。