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

This is a discussion on error C2064: term does not evaluate to a function taking 2 arguments within the C++ Programming forums, part of the General Programming Boards category; Hey guys, I'm trying to create a little program here, but I'm having some trouble with it. I'm getting the ...

  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,185
    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,185
    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,185
    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
    21,647
    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.
    C + C++ Compiler: MinGW port of GCC
    Version Control System: Bazaar

    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  8. #8
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,498
    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.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

  9. #9
    C++まいる!Cをこわせ! Elysia's Avatar
    Join Date
    Oct 2007
    Posts
    22,548
    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, 08: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, 07:55 AM
  5. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM

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