trying to write a class

I am not sure what my question is. I don't know enough to know what I don't know. I have spend 30+hours trying to figure this out. I keep getting the same error "PointMain.cpp:(.text+0x4c): undefined reference to `Point::Point()'
collect2: ld returned 1 exit status" Does anyone have any idea what I'm doing wrong?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//This is my header File

#ifndef Point_hpp
#define Point_hpp

class Point

{
private:
    double xCoord;
    double yCoord;
    
public:
    void setXCoord (double);
    void setYCoord (double);
    double getXCoord (double);
    double getYCoord (double);
    
    Point ();
    Point (double xCoord, double yCoord);
    
    double distanceTo (double, double);
};
    

#endif


// This is my Point file
#include "Point.hpp"
#include <iostream>
#include <cmath>  //for sqrt and pow


Point::Point()
{
    setxCoord(0);
    setyCoord(0);
}

Point::Point(double xCoord, double yCoord)
{
    setXCoord(xcoor);
    setYCoord(ycoor);
    
}

void Point::setXCoord(double xcoor)
    {
        xCoord=xcoor;
    }

void Point::setYCoord(double ycoor)
    {
        yCoord=ycoor;
    }

double Point::getXCoord (double xCoord)
    {
        return xCoord;
    }

double Point::getYCoord (double YCoord)
    {
        return yCoord;
    }

double Point::distanceTo (double x2, double y2)
    {
        return sqrt(pow((xCoord - x2), 2) + pow ((yCoord - y2),2));
    }
The x and y should be capitalized.
1
2
    setxCoord(0);
    setyCoord(0);


The C should be capitalized
1
2
    setXCoord(xcoor);
    setYCoord(ycoor);


Other than that it compiles without error for me.
Last edited on
Topic archived. No new replies allowed.