"hata C2660: 'storeInitialValues': işlev oluşturmaya çalışırken kod günlüğümde 1 bağımsız değişken almaz. Burada yayınlanan bazı geçmiş hatalara baktım ve bence/userf, v, dsize ve/veya asize ile bir çeşit başlatma hatası olabilir. Ben sadece storeInitialValues (userize, v, dsize, asize) özel çağrısında hata görmek istiyorum; bu kadar. Şimdiden çok teşekkür ederim.Merhaba, Sadece bu hata ne demektir bilmek istiyorum
#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()
{
}
Bu işlevin 5 parametre aldığını, ancak yalnızca 4 parametre ile çağırdığını görüyoruz. Ayrıca, sizde vektörünüz var, ama garip bir sebepten ötürü, bunun için kullanılması gereken şeyler için kullanmıyorsunuz. Int * temp = new int [usersize]; '' basitçe 'std :: vector temp (usersize) 'ile değiştirilebilir;' –
PaulMcKenzie
storeInitialValues işlevi, yalnızca 4 tane argüman alır 4.Also olarak * ve yanlış görünüyor. Girişi * olarak tanımlayın ve adresi iletin. –
Lütfen sorunuzun başlığını özellikle yazınız. –