Hi people,in the assignment I was give the main function and was told to write a class, and the output is supposed to be like this:
BLANK(0,0)
Destination (6.2,16,7)
BLANK (45,0)
Destination (6.2,33.4)
The x coordinate of source is:45
The y coordinate of source is :33.4
The label of point source is:BLANK
The new label of point source is : SOURCE
But my compiler gives me error like:"undefined reference to"to all my functions.Could someone help me please????
#include "Point.h"
Point::Point()
{
x = 0;
y = 0;
l="BLANK";
}
Point::Point( double nx, double ny,string nl )
{
x=nx;
y=ny;
l=nl;
}
void Point::set_x( double nx )
{
x=nx;
}
void Point::set_y( double ny )
{
y=ny;
}
void Point::set_label(string nl)
{ l=nl;
}
double Point::get_x() const
{
return x;
}
double Point::get_y() const
{
return y;
}
string Point::get_label() const
{ return l;
}
void Point::print() const
{
cout<<l<<x<<y<<endl;
}
#ifndef POINT_H
#define POINT_H
#include <iostream>
#include <string>
using namespace std;
class Point
{
public:
Point();
Point( double nx, double ny,string nl );
double get_x() const;
double get_y() const;
string get_label()const;
void set_x( double nx );
void set_y( double ny );
void set_label(string label);
void print() const;
private:
double x, y;
string l;
};
#endif
#include "point.h"
int main(void)
{
Point source; // default constructor called
Point destination(6.2, 16.7, "Destination"); // constructor called
source.print();
destination.print();
source.set_x(45);
destination.set_y(33.4);
source.print();
destination.print();
cout << "The x coordinate of point source is: "
<< source.get_x() << endl;
cout << "The y coordinate of point destination is: "
<< destination.get_y() << endl;
cout << "The label of point source is: " << source.get_label() << endl;
source.set_label("SOURCE");
cout << "The new label of point source is: " << source.get_label()<< endl;
cout << "----- Program ends here -----" << endl;
return 0;
}