I am learning structures, pointers, and header files in c++. I have begun a project that I found on the internet and am getting stuck very early on. Here is the error:
undefined reference to `readPoly(Polygon&)' collect2.exe: error: ld returned 1 exit status
and the code of all the included files:
Main:
#include <iostream> // C++ input/output library
#include "Point.h"
#include "Polygon.h"
using namespace std;
int main()
{
struct Point vertices[20];
struct Polygon poly[10];
char command;
int counter = 0;
while(1)
{
cout << "Enter command (A | P | T | X): ";
cin >> command;
while(command != 'A' && command != 'a' && command != 'P' && command != 'p' && command != 'T' && command != 't' && command != 'X' && command != 'x')
{
cout << "Improper command. Try again: ";
cin >> command;
}
switch(command)
{
case 'A': case 'a':
readPoly(poly[10]);
case 'P': case 'p':
break;
case 'T': case 't':
break;
case 'X': case 'x':
return 0;
}
}
}
Polygon.h:
struct Polygon
{
struct Point vertices[10];
int verts;
};
void printPoly(Polygon &pol);
void readPoly(Polygon &pol);
Point.cpp:
#include "Point.h"
void printPoint(Point &pt)
{
}
void readPoint(Point &pt)
{
}
Point.h:
struct Point
{
double x; // X coordinate
double y; // Y coordinate
};
void printPoint(Point &pt);
void readPoint(Point &pt);