I have this algorithm from my c++ class that i can't get to work, it doesn't compile (mainly because is wrong) and I have no idea on how to fix it. It supposed to be a global function that takes an array of 10 and gives 10 random numbers from -10 to 10, using a Point class. Here's what I have.

``````#include <iostream>
#include <cmath>
using namespace std;

class Point {
private:
double x;
double y;
public:
void set_data(double xval, double yval);
void get_data(double &xout, double &yout);
Point();
Point(double xval, double yval);
void output(Point a[], int size);
void print();
};
void init_point_array(Point a[], int n);

int main (){
Point a;
init_point_array(a, 5);

system ("pause");
return 0;
}
void Point::output(Point a[], int size){
for (int i=0; i<size; i++){
return a[i];}}
void Point::print(){cout<<"{"<<x<<","<<y<<"}";}
void Point::set_data(double xval, double yval){xval=x;yval=y;}
void Point::get_data(double &xout, double &yout){xout=x;yout=y;}
Point::Point(){x=0.0;y=0.0;}
Point::Point(double xval, double yval){x=xval;y=yval;}

void init_point_array(Point a[], int n){
for(int i=0;i<n;i++){a[i].set_data(rand()%21-10,rand()%21-10);}
}
void output(Point a[], int size){
for (int i=0; i<size; i++){
cout<<a[i]
}
}``````

You are trying to return a class object when your function says its return type is void...you missed a semi colon, and you are trying to cout<< a class object, so you either need to change what you are trying to cout or overload the << operator

Chris