Help!!

This is a discussion on Help!! within the C++ Programming forums, part of the General Programming Boards category; Is there anything that stands out in the following code that could cause me to get the error message "comparison ...

  1. #1
    Registered User
    Join Date
    Apr 2010
    Posts
    1

    Help!!

    Is there anything that stands out in the following code that could cause me to get the error message "comparison between distinct pointer types lacks a cast" upon trying to compile it? I'm brand new to programming, so I apologize in advance if this code is hideous. . .

    Code:
    #include <iostream>
    #include <cmath>
    #include "is_an_op.h"
    using namespace std;
    
    double do_op(char op, double num_one, double num_two)
    {
            if (op == '/') && (num_two == 0)
               return 0.0;
            else if (is_an_op == "true") && (op == '+')
               return num_one + num_two;
            else if (is_an_op == "true") && (op == '-')
               return num_one - num_two;
            else if (is_an_op == "true") && (op == '*')
               return num_one * num_two;
            else if (is_an_op == "true") && (op == '/')
               return num_one / num_two;
            else
               return 0.0;
    }
    Thanks!

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,185
    You probably want to call is_an_op, not use it as a pointer to a function.

  3. #3
    Or working on it anyways mramazing's Avatar
    Join Date
    Dec 2005
    Location
    Lehi, UT
    Posts
    121
    are you using a character array when calling the function?
    -- Will you show me how to c++?

Popular pages Recent additions subscribe to a feed

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