So I'm getting an expected unqualified-id error in the code below. It's a file being called by the main in another file. They are compiled together using g++. Any hints or ideas of what's wrong?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
#include <iostream>
#include <cstdlib>
usingnamespace std;
int[] expand_array(int a[], int l, int inc); //error on this line, character 4
int[] expand_array(int a[], int l, int inc) //error on this line, character 4
{
int newa[l + inc];
for(int i = 0; i < l; i++)
{
newa[i] = a[i];
}
return newa[];
}
You'll either have to pass the array by reference as ceruleus suggested, or you'll have to put it in a container class (like a vector) or something similar and return that.