So I finally get to the end of this evil program, and then it won't compile because it says "type double not expected".

Here is my error message in its entirety:
program 3 item.cpp(111) : error C2062: type 'double' unexpected
program 3 item.cpp(121) : error C2062: type 'double' unexpected
program 3 item.cpp(131) : error C2062: type 'double' unexpected

And here is a link to my codes (with the line numbers, so hopefully it won't be that hard to see what I'm doing wrong)
http://pastebin.com/mff1e676

Thanks for the help :)

Recommended Answers

All 6 Replies

This is line 111

height_earth = double distance_earth(float speed, double radians)* (tan(radians)) - (G_earth * (pow(double distance_earth(float speed, double radians), 2))) / ((2(pow((speed)(cos(radians), 2)))));

should probably be:

height_earth = distance_earth(speed, radians)* (tan(radians)) - (G_earth * (pow(distance_earth(speed, radians), 2))) / ((2(pow((speed)(cos(radians), 2)))));
commented: thanks man +1

Hmm...no man, that only makes it a LOT worse, but thanks for trying. I appreciate it. Here's some rep ;)

Hmm...no man, that only makes it a LOT worse, but thanks for trying. I appreciate it. Here's some rep ;)

I said it should probably be - you have some very serious errors in your code. The foremost is you don't know how to call a function..

Hmm...no man, that only makes it a LOT worse, but thanks for trying. I appreciate it. Here's some rep ;)

At any rate, if you haven't noticed, this is a forum on C not C++. You should post your questions in the correct forum.

You'll need to make a lot of changes to your functions given this sort of pattern...

From (extraneous type needs to be removed, multiplication is done using * , feed the pow function the correct number of parameters):

double height_moon (float speed, double radians, double distance_moon(float speed, double radians))
{
	double height_moon, G_moon;
	G_moon = 1.62;

	height_moon = double distance_moon(float speed, double radians) * (tan(radians)) - (G_moon * (pow(double distance_moon(float speed, double radians), 2))) / ((2(pow((speed)(cos(radians), 2)))));
	return height_moon;
}

To:

double height_moon (float speed, double radians, double distance_moon(float speed, double radians))
{
   double height_moon, G_moon;
   G_moon = 1.62;

   height_moon = distance_moon(speed, radians) * (tan(radians)) - (G_moon * (pow(distance_moon(speed, radians), 2))) / ((2 * (pow(speed, (cos(radians), 2)))));
   return height_moon;
}

Removing the type was already mentioned. I don't know how you found that correcting your code "only makes it a LOT worse".

If you're attempting to cast the variables to a different type, the type needs to be enclosed in parentheses. e.g., (double) distance_moon((float) speed, (double) radians). If the variables are defined as the proper type to begin with, there is no need to cast them. Specifying types is appropriate in the function prototype or header, but not in the call to the procedure.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.