Passing structures to a function

I'm really lost on how to pass my structure to a function.

Basically I have the listed structures, and I need to pass them to a function for conversion. Can someone please help me?

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
#include <iostream>		// contains cout/cin functions
#include <cmath>		// contains trig functions
using namespace std;
//______________________________________________________________________________
// Prototypes:
    //void convert_to_radians(char, int, int, int, double&, double&);
	void convert_to_radians(point);
//______________________________________________________________________________
// Main function:
int main() {

	const double RADIUS = 3958.89;

	struct coordinate {
		char direction;
		double degrees;
		double minutes;
		double seconds;
	} ;

	struct point {
		coordinate latitude;
		coordinate longitude;
		double alpha;
		double beta;
	} first, second;

	double theta;

	cout << "This program will calculate the distance between two coordinates on Earth." << endl
		<< "Please enter your coordinates in the following format:" << endl
		<< "	(N, S, E, or W) (Degrees) (Minutes) (Seconds)" << endl
		<< "	i.e. N 95 18 35" << endl
		<< "Enter the latitude of the first coordinate:" << endl;
	cin >> first.latitude.direction >> first.latitude.degrees >> first.latitude.minutes >> first.latitude.seconds;
	cout << "Enter the longitude of the first coordinate:" << endl;
	cin >> first.longitude.direction >> first.longitude.degrees >> first.longitude.minutes >> first.longitude.seconds;
	cout << "Enter the latitude of the second coordinate:" << endl;
	cin >> second.latitude.direction >> second.latitude.degrees >> second.latitude.minutes >> second.latitude.seconds;
	cout << "Enter the longitude of the second coordinate:" << endl;
	cin >> second.longitude.direction >> second.longitude.degrees >> second.longitude.minutes >> second.longitude.seconds;

	convert_to_radians(point);
	system("PAUSE");
    return 0;
}
//______________________________________________________________________________
// Function definitions:
    
//void calc_maximum(int Val1, int Val2, int Val3, int Val4, int& Max1, int& Max2) {
void convert_to_radians(point) {

	double degrees=0;

	cout << degrees << endl;

	degrees += first.latitude.degrees;

	cout degrees << endl;
	
}


I get the following errors:

1>------ Build started: Project: project1, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(7): error C2065: 'point' : undeclared identifier
1>c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(7): error C2182: 'convert_to_radians' : illegal use of type 'void'
1>c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(43): error C2275: 'main::point' : illegal use of this type as an expression
1>          c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(21) : see declaration of 'main::point'
1>c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(51): error C2065: 'point' : undeclared identifier
1>c:\users\matt\dropbox\egr125\project\project1\project1\main.cpp(51): error C2448: 'convert_to_radians' : function-style initializer appears to be a function definition
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


I suppose I'm really just not sure what is going on exactly. I read the tutorial and it seems to work well for their case, but I'm not sure how to apply that to my program. If I move my structures outside the main function, I get a lot more errors.

Thanks for the assistance in advance!
closed account (zb0S216C)
The first error is pointing to the argument list on line 51. Your first and only argument is incomplete.

point is declared and defined locally to main. However, convert_to_radians( ) is global. Here's a hint: point does not exist to convert_to_radians( ).
Last edited on
Topic archived. No new replies allowed.