#1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    11

    ahhhhh.! don't understand this one error


    //sam huang
    //Cs 209-2393
    //Pointers
    //Sept. 18, 2003
    #include <iostream>
    using namespace std;
    void main()
    {
    float mul;
    int a=3;
    int b=4;
    int *pa=&a;
    cout<<"address of a"<<pa;
    *pa=a;
    cout<<"contents of *pa"<<*pa;

    int *pb=&b;
    cout<<"\n &b"<<pb;
    cout<<"b="<<*pb;

    int V= mul(&a, &b);
    cout<<"\n a+b="<<V;
    return;
    }


    int mul(int *pta, int*ptb)
    {
    int c=*pta**ptb;
    return(c);
    }



    Line 21: error C2064: term does not evaluate to a function...:rolleyes:
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Maybe your compiler is getting confused by this statement:
    int c=*pta**ptb;

    Try rewriting this as:
    int c = (*pta) * (*ptb);
    or:
    int c = *pta * *ptr;

    Spaces are a good thing :)
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo
  4. #3
  5. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,110
    Rep Power
    1803
    In line 21, you are calling mul() before it is declared or defined. There are two ways around this.

    1) Define mul() ahead of main().
    2) Forward declare mul() by adding the following before main():
    Code:
    int mul( int* pta, int* ptb ) ;
    Scorpions4ever 's suggestion is not the answer, but he is right, your code layout sucks and your use of whitspace is inconsistent. Also remembering to post in code tags will aid readability.

    And another point to save me counting lines and hoping that you have not missed out lines, please indicate the line for which the error was reported in the code, in this case line 21.

    Clifford
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    11
    It still doens't work. the problem is in line 22, which is..

    int V= mul(&a, &b);

    error C2064: term does not evaluate to a function
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2003
    Posts
    54
    Rep Power
    12
    You have a variable with the same name as your function. The strange thing is.. that variable is never even used.

    Make the changes that clifford suggested and then take this line out of your main function:

    Code:
    float mul;
    And it should work.
  10. #6
  11. Contributing User

    Join Date
    Aug 2003
    Location
    UK
    Posts
    5,110
    Rep Power
    1803
    Also you need to forward declare mul().
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2003
    Posts
    90
    Rep Power
    11
    it works...=) thanks!!!

IMN logo majestic logo threadwatch logo seochat tools logo