Thread: error C2064: term does not evaluate to a function taking 2 arguments

  1. #1
    village skeptic
    Join Date
    Aug 2008
    Posts
    31

    error C2064: term does not evaluate to a function taking 2 arguments

    Hey guys, I'm trying to create a little program here, but I'm having some trouble with it.

    I'm getting the following error message: error C2064: term does not evaluate to a function taking 2 arguments. I don't really kn ow what the hell that means, would someone mind pointing out what the problem is so I can fix it? I was under the impression that a function as an argument was perfectly cool to do. Anyway, here are the two offensive lines, followed by the function definitions.

    Code:
     
    //bad lines
    x += delta_x((velocity_x(user_velocity, DEGREES)), t);
    y -= delta_y((velocity_y(user_velocity, DEGREES)), t);
    
    //function definitions: 
    double velocity_x(int vel, int degrees){
    	return vel * cos(degrees * 3.141592654/180.0);
    }
    double velocity_y(int vel, int degrees){
    	return vel * sin(degrees * 3.141592654/180.0);
    }
    
    
    double delta_x(double vel_x, double time){
    	return vel_x * time;
    }
    double delta_y(double vel_y, double time){
    	return vel_y * time - (.5 * (9.8 * (time*time)));
    }
    Any help would be greatly appreciated, because I have no idea what is wrong.

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Do you have prototypes for your functions?

  3. #3
    village skeptic
    Join Date
    Aug 2008
    Posts
    31
    yes I do, at the top of my file:

    Code:
    double velocity_x(int vel, int degrees);
    double velocity_y(int vel, int degrees);
    double delta_x(double vel_x, double time);
    double delta_y(double vel_y, double time);

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Good. Then you're not getting that error. (No really. I just compiled it, and you're not getting any error at all.)

  5. #5
    village skeptic
    Join Date
    Aug 2008
    Posts
    31
    I'm confused. It still fails compilation for me.

  6. #6
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    It shouldn't make a difference, but remove the superfluous parentheses around the function calls and see if that helps. After that, I don't know. I'm using VS2008; I don't know what version you have, but you may need to yell.

  7. #7
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Quote Originally Posted by misterMatt
    I'm confused. It still fails compilation for me.
    Provide the smallest and simplest complete program that demonstrates the error.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    x += delta_x((velocity_x(user_velocity, DEGREES)), t);
    y -= delta_y((velocity_y(user_velocity, DEGREES)), t);
    You've got local variables with the same names in whatever function you've got this code in.

    One way out
    Code:
    x += delta_x((::velocity_x(user_velocity, DEGREES)), t);
    y -= delta_y((::velocity_y(user_velocity, DEGREES)), t);
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  9. #9
    C++まいる!Cをこわせ!
    Join Date
    Oct 2007
    Location
    Inside my computer
    Posts
    24,654
    It's better to rename the functions (and/or the variables) to something different.
    Quote Originally Posted by Adak View Post
    io.h certainly IS included in some modern compilers. It is no longer part of the standard for C, but it is nevertheless, included in the very latest Pelles C versions.
    Quote Originally Posted by Salem View Post
    You mean it's included as a crutch to help ancient programmers limp along without them having to relearn too much.

    Outside of your DOS world, your header file is meaningless.

  10. #10
    Banned master5001's Avatar
    Join Date
    Aug 2001
    Location
    Visalia, CA, USA
    Posts
    3,685
    Off topic...

    Code:
    #include <math.h>
    
    double velocity_x(int vel, int degrees){
    	return vel * cos(degrees * M_PI/180.0);
    }
    double velocity_y(int vel, int degrees){
    	return vel * sin(degrees * M_PI/180.0);
    }

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Problem Displaying a Struct
    By rockstarpirate in forum C++ Programming
    Replies: 16
    Last Post: 05-05-2008, 09:05 AM
  2. recursion error
    By cchallenged in forum C Programming
    Replies: 2
    Last Post: 12-18-2006, 09:15 AM
  3. Calling a Thread with a Function Pointer.
    By ScrollMaster in forum Windows Programming
    Replies: 6
    Last Post: 06-10-2006, 08:56 AM
  4. Change this program so it uses function??
    By stormfront in forum C Programming
    Replies: 8
    Last Post: 11-01-2005, 08:55 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM