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[5];
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]
}
}