array overwrite/bad pointer?

/*-------------------------------------------------------
1. 3 Algorithms to find the smallest sum from consecutive numbers.
-------------------------------------------------------
*/
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
* Alg _ 1, linear,
*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
*/
class Alg_1{
public:
Alg_1();
~Alg_1();
void solve(const int a1_Arr[],const int length);
int psum();//positive sum
int nsum();//negative sum

private:
int array[];
int location;
...
};
...
void Alg_1::solve(const int a1_Arr[], const int length){
*array = *a1_Arr;
...
};

...
};

int main(){
/**--------------------------------------------------------
4. gets 10 integers from the user and runs the three
algorithms with the same input, with output on the console
--------------------------------------------------------
*/
int temp1;
int simpleA[10];
cout<<"Please type 10 integers, -100 to 100"<<endl;

for(int i=0; i<10; i++){
cin >>temp1;
simpleA[i]=temp1;
}

Alg_1 alg1A;
Alg_2 alg2A;

alg1A.solve(simpleA, 10);
...
}


I can post more code if needed, but my problem is this: although it compiles nice, the array changes inside of the algorithm class. The values are different. Thank you in advance for any direction
private:
int array[];

has no meaning. You have to give the array a size or else you have to dynamically allocate it.

*array = *a1_Arr;

will copy only 1 element from the array.
thanks- i changed it to a dynamically allocated array and that solved my problems
Topic archived. No new replies allowed.