So, the problem happens around line 35 (where I call the edgeList constructor). Whenever it gets to that point I get the error
main.cpp:35:60: error: no matching function for call to 'point::point()'
Here's the problem area
class edgeList {
private:
point origin;
point terminal;
double weight;
public:
edgeList(const point& origin, const point& terminal) {
this->origin = origin;
this->terminal = terminal;
this->weight = findWeight(origin, terminal);
}
int findWeight(point origin, point terminal) {
return sqrt(pow((terminal.place('x') - origin.place('x')), 2) + pow((terminal.place('y') - origin.place('y')), 2));
}
};
And here's the full code
#include <iostream>
#include <string.h>
#include <fstream>
#include <vector>
#include <math.h>
using namespace std;
class point { //Creates the class that stores x and y coordinates
private:
double x;
double y;
public:
point(double x, double y) {
this->x = x;
this->y = y;
}
double place(char c) {
if (c == 'x') {
return this->x;
}
else if (c == 'y') {
return this->y;
}
else {
return -1;
}
}
};
class edgeList {
private:
point origin;
point terminal;
double weight;
public:
edgeList(const point& origin, const point& terminal) {
this->origin = origin;
this->terminal = terminal;
this->weight = findWeight(origin, terminal);
}
int findWeight(point origin, point terminal) {
return sqrt(pow((terminal.place('x') - origin.place('x')), 2) + pow((terminal.place('y') - origin.place('y')), 2));
}
};
int main(int argc, char *argv[]) {
double x;
double y;
int i = 0; //FIXME: DELETE THIS AFTER TESTING
vector<point> origin;
if (argv[1] == NULL) {
cout << "ERROR: NO FILE NAME FOUND" << endl;
return -1;
}
if (strcmp(argv[1], "random") != 0) {
cout << argv[1] << endl;
ifstream fp;
fp.open(argv[1]);
if (!fp.is_open()) {
cout << "ERROR: NO FILE FOUND" << endl;
return -1;
}
while (!fp.eof()) {
fp >> x;
cout << x << " ";
fp >> y;
cout << y << endl;
point pnt(x,y);
origin.push_back(pnt);
cout << "Point children" << endl << origin[i].place('x') << " " << origin[i].place('y') << endl;
i++; //FIXME: DELETE THIS AFTER TESTING
}
edgeList z(origin[0], origin[1]);
}
return 0;
}
What am I doing wrong here?