我已经阅读了很多关于此类问题的帖子,但我仍然无法看到我所遗漏的内容。
我已经创建了一个模块,代码如下:
void create_array(int numbers[], int& count)
{
int num; //number to be entered into the array
//set counter to zero
count = 0;
//Read from file
ifstream infile;
infile.open("data");
if (infile.fail())
cerr << "ERROR opening input file 'data.'\n";
else
infile >> num;
while (!infile.eof() && count < arraysize)
{
numbers[count] = num;
count++;
infile >> num;
}
if (!infile.eof())
cerr << "WARNING: Array size exceeded. Input has stopped.\n";
infile.close();
cout << "Input read from the file 'data'\n";
}
(抱歉格式不佳)
主要功能是:
#include <iostream>
#include <fstream>
#include <iomanip>
#include "constants.h"
using namespace std;
//function prototypes
void create_array(int numbers[], int& count);
int main()
{
//Variables
int numbers[arraysize], //array created by file input
count; //counter for array size
create_array(numbers, count);
return 0;
}
当我尝试编译main函数时,我得到&#34;未定义引用&#39; create_array(int *, INT&安培;)
我一直在阅读有关匹配符号的内容,所以我的第一个假设是我的数组导致了这个问题,但数组总是通过引用传递...那么我做错了什么?
感谢。