|
| Hi call,
"man gcc" stated that gcc is a c++ compiler. However, I have the following
*VERY SIMPLE* code in c++ that doesn't compile in gcc. It compiles fine in
VC++ 7.0. I have no clue why. TIA
Error message:
gcc test.cc
/tmp/ccMJrkgw.o(.text+0x18): In function `main':
: undefined reference to `Point::Point[in-charge]()'
/tmp/ccMJrkgw.o(.text+0x3f): In function `main':
: undefined reference to `Point::Point[in-charge](double, double)'
/tmp/ccMJrkgw.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status
test.cc:
#include "Point.h"
#include <stdio.h>
int main()
{
Point a;
Point b(3, 4);
//printf("Distance is %f", a.getDistance(b));
return 0;
}
Point.h:
#ifndef Point_H
#define Point_H
class Point
{
private:
double m_x, m_y;
public:
Point();
Point(double x, double y);
double getDistance(Point p);
void setPoint(double x, double y);
double getX();
double getY();
};
#endif
Point.cc:
#include "Point.h"
#include <math.h>
Point::Point()
{
setPoint(0, 0);
}
Point::Point(double x, double y)
{
setPoint(x, y);
}
void Point::setPoint(double x, double y)
{
m_x = x;
m_y = y;
}
double Point::getX()
{
return m_x;
}
double Point::getY()
{
return m_y;
}
double Point::getDistance(Point p)
{
return pow(pow(p.getX() - m_x, 2) + pow(p.getY() - m_y, 2), 0.5);
}
|
|