在CodeLite中使用未声明的标识符“insertionSort”

时间:2016-08-05 06:09:27

标签: c++ codelite

在Mac上使用CodeLite IDE来刷新我的C ++。 在与具有main()的文件不同的cpp文件中编写函数是一种常见的做法。 我有两个.cpp文件,main.cpp和InsertionSort.cpp。 后者具有分类功能和打印功能。

主要内容如下:

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

int main(int argc, char **argv) 
{
    int unsorted[6] = {5,2,4,6,1,3};
    int size = 6;
    insertionSort(unsorted, size);
    printArray(unsorted, size);     
}

和另一个insertSort.cpp如下:

#include <stdio.h>
#include <stdlib.h>
#include <iostream>

using namespace std;

void printArray(int*,int);

void insertionSort ( int array[], int size)
{

int value = 0; //temp variable to store the value of the element being moved
int holeIndex = 0; // index variable to keep track of the vacant slot
for (int i = 1; i <= size ; i++)
{
    value  = array[i];
    holeIndex = i;
    while(holeIndex > 0 && value < array[holeIndex-1])
    {
        array[holeIndex] = array[holeIndex -1];
        holeIndex = holeIndex -1 ;
    }
    array[holeIndex] = value;
    printArray(array,size);
}
//return array;
}

void printArray(int array[], int size)
{
for (int i = 0; i<size; i++ )
{
    cout << array[i]<<" ";
}
    cout << endl;
}

我面临的问题是,当我运行这个时,我得到一个未声明的标识符'insertionSort'和未声明的标识符'printArray'。 这似乎是一个导入问题,但我无法在CodeLite中弄明白。 此外,导入其他源.cpp文件的任何一般经验法则,所以我不再遇到这个noob问题? 任何帮助将不胜感激。 提前致谢。

任何包含我都不见了?

0 个答案:

没有答案