Question: This is my code: shape.h: #ifndef SHAPE_H #define SHAPE_H #include #include using namespace std; class Shape{ private: struct Point{ double x, y; }; vector points;

This is my code: shape.h:

#ifndef SHAPE_H

#define SHAPE_H

#include

#include

using namespace std;

class Shape{

private:

struct Point{

double x, y;

};

vector points;

public:

void addPoint(Point p);

Point getPoint(int);

int getNumPoints(void);

};

#endif

shape.cpp:

#include "shape.h"

using namespace std;

Shape::Shape(){}

void addPoint(Point p){

points.push_back(Point p);

}

Point getPoint(int i){

return points[i];

}

int getNumPoints(void){

return points.size();

}

Main.cpp:

#include

#include "Shape.h"

#include

#include

using namespace std;

struct Point{

double x,y;

};

int main(int argc, char* argv[]){

Shape shape1;

ifstream shapeOne;

shapeOne.open(argv[1]); // Test to see if file opened correctly.

if(!shapeOne){

cout << "File not found, enter correct file name." << endl;

return 1;

}

Point p1, p2, p3, p4; //Adding Point struct objects.

shapeOne >> p1.x >> p1.y >> p2.x >> p2.y >> p3.x >> p3.y >> p4.x >> p4.y; //Storing file points into struct Point variables.

shapeOne.close();

//Adding points to

shape1.addPoint(p1);

shape1.addPoint(p2);

shape1.addPoint(p3);

shape1.addPoint(p4);

return 0;

}

In my code, I am getting an error "[Error] no matching function for call to 'Shape::addPoint(Point&)' and I've got no idea why.

This is c++

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!