error saying undefined reference to a function

I'm a beginner to c++
The code compiled and ran successfully a few days ago but i'm getting errors now
errors saying undefined reference to all my functions
and I put all three under the same project
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
 #include "coord.h"
#include <iostream>
#include <cmath>
using namespace std;

void get_point (Point3D &p) {
	cout << "Enter the ID which must be an integer." <<endl;
	cin >> p.id;
	cout << "You enterd " <<p.id << " for the ID" <<endl;
	cout << "What is the x coordinate?" <<endl;
	cin >> p.x;
	cout << "You enterd " <<p.x << " for the x coordinate " <<endl;
	cout << "What is the y coordinate?" <<endl;
	cin >> p.y;	
	cout << "You enterd " <<p.y << " for the y coordinate " <<endl;
	cout << "What is the z coordinate?" <<endl;
	cin >> p.z;
	cout << "You enterd " <<p.z << " for the z coordinate " <<endl;
	cout << "What is the accuracy of the point? Enter A fot high accuracy, B for medium accuracy, and C for low accuracy." <<endl;
	cin >> p.order;
	cout << "You enterd " <<p.order << " for the accuracy of the point " <<endl;
}

void print_point(const Point3D p) { 
	cout << "Coordinates of Point " << p.id << ": " 
		<< "x= " << p.x << ", y= " << p.y << ", z=" << p.z << endl;
	cout << "Accuracy (order) of Point " << p.id << ": " << p.order << endl;
		
}

void spatial_dist( double &ds, Point3D p1, Point3D p2) { //compute the plani distance
	ds = sqrt(pow(p2.x - p1.x, 2)+pow(p2.y - p1.y, 2) +pow(p2.z- p1.z, 2)); //point
	
}

void plani_dist( double &dp, Point3D p1, Point3D p2) { //compute the plani distance
	dp = sqrt(pow(p1.x- p2.x, 2)+pow(p1.y - p2.y, 2));
	
}
void ht_diff( double &ht, Point3D p1, Point3D p2 ) { //compute the height difference
	ht = p2.z - p1.z;
}

void azimuth(double &theta, Point3D p1, Point3D p2) { // compute the azimuth (heading)
	theta = atan((p2.y - p1.y)/(p2.x- p1.x));
	
	
}

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

#include <iostream>
#include "coord.h"
using namespace std;



int main () //declare two variables of type Point3D, called point1 and point2
{
	Point3D point1;
	Point3D point2;
	double ds = 0.0;
	double dp =0.0;
	double ht =0.0;
	
	// input fields of structs
	get_point(point1);
	get_point(point2);
	print_point(point1); 
	print_point(point2); 
	spatial_dist(ds, point1, point2);
	plani_dist(dp, point1, point2);
	ht_diff(ht, point1, point2);
	
	cout << "Spatial Distance: " << ds << endl 
		<< "Planimetric distance: " << dp << endl 
		<< "Height difference: " << ht << endl;
		
	return 0;
}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22


#ifndef COORD_H
#define COORD_H
#include <iostream>
using namespace std;


struct Point3D {
	int id;
	double x;
	double y;
	double z;
	char order; //representing the accuracy of the point (A = high accuracy, B = medium accuracy and C = low accuracy). 
};

void get_point (Point3D &p);
void print_point( const Point3D p ); 
void spatial_dist( double &ds, Point3D p1, Point3D p2 );
void plani_dist( double &dp, Point3D p1, Point3D p2 );
void ht_diff( double &ht, Point3D p1, Point3D p2 );
#endif 
Last edited on
code compiles fine on my VC compiler. getting a few warnings but thats about it.

what IDE are you using?
Last edited on
Topic archived. No new replies allowed.