2016-05-04 43 views
-2

我必须制作2个数组并使用函数来输入,输出,添加和比较它们,但我总是收到错误消息:undefined reference to outputVLI(int*, int)。我不确定这意味着什么或如何解决它。任何帮助,将不胜感激未定义的对outputVLI的引用?

#include <iostream> 
using namespace std; 

const int maxDigits = 100; 
void inputVLI (int vli[], int size); // Inputs the very long integers 
void outputVLI (int vli[], int size); // Outputs the very long integers 
void addVLI (const int vli1[], const int vli2[], int vli3[], int size1, int size2, int& size3); // Adds the very long integers together 
int compVLI (const int vli1, const int vli2, int size1, int size2); // Compares the very long integers 

int main() 
{ 
    int vli1[maxDigits], vli2[maxDigits], vli3[maxDigits], size1, size2, size3; 
    inputVLI (vli1, maxDigits);         // Calls the individual functions 
    outputVLI (vli1, maxDigits);        // | 
    inputVLI (vli2, maxDigits);         // | 
    outputVLI (vli2, maxDigits);        // | 
    /*addVLI (vli1, vli2, vli3, size1, size2, size3);   // | 
    compVLI (vli1, vli2, size1, size2);*/      // \/ 
    return 0; 
} 

void inputVLI(int vli[], int size) 
{ 
    cout << "Enter a very long integer" << endl; 
    cin >> vli[maxDigits]; 
} 

void output (int vli[], int size) 
{ 
    for (int i=maxDigits; i>=0; i--) 
     cout << vli[i]; 
} 

void addVLI (const int vli1[], const int vli2[], int vli3[], int size1, int size2, int& size3) 
{ 
/* 
    for (int i=0; i<maxDigits; i++) 
    { 
     vli3[i]=vli1[i] + vli2[i]; 
     cout << "The sum of the vli's is:" << vli3[i] << endl; 
    } 
*/ 
} 

int compVLI (const int vli1, const int vli2, int size1, int size2) 
{ 
/* 
    for (int i=0; vli1[maxDigits] && vli2[maxDigits]; i++) 
    { 
     if (vli1[maxDigits] != vli2[maxDigits]) 
     { 
      return (-1); // -1 is not equal 
     } 
     return (1); // 1 is equal 
    } 
*/ 
} 

回答

0

outputVLI功能declared, but not defined。所以,你应该添加的定义:

void outputVLI(int vli[], int size) { 
    // TODO: implementation here 
} 

此外,您compVLI函数需要返回一个值...

+0

我不知道你是什么意思,怎么样了它没有定义? – awpirates9

+0

看看我链接到的答案。你需要声明你的函数(即'void foo();'),你需要定义你的函数(即'void foo(){}')。如果您在使用功能之前定义了功能,则可以跳过声明。 – miha