comparing return values from functions

This is a discussion on comparing return values from functions within the C++ Programming forums, part of the General Programming Boards category; I am trying to compare a value returned by a function within a class object with a set value... Code: ...

  1. #1
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    121

    comparing return values from functions

    I am trying to compare a value returned by a function within a class object with a set value...

    Code:
    if (theCircuit.at(i)->getType() == 3) { ...some code... }
    at compilation, the following error:

    Code:
    D:\WORK\CIRCUIT.CPP(101) : error C2446: '==' : no conversion from 'const int' to 'int (__thiscall LogicGate::*)(void)'
            There are no conversions from integral values to pointer-to-member values
    the function that is being used is:

    Code:
    int LogicGate::getType(){
    	return gateType;     // gateType is a private int for class LogicGate
    }
    What i want to do is compare the gateType variable, in order to find out the type of gate that is at the current position in the vector!!!

  2. #2
    Registered User
    Join Date
    Jan 2005
    Posts
    7,328
    Are you sure you didn't actually type:
    Code:
    if (theCircuit.at(i)->getType == 3)
    with missing parentheses after getType?

  3. #3
    Matt Conway bobthebullet990's Avatar
    Join Date
    Nov 2005
    Location
    Cambridge
    Posts
    121
    Yep... its definatley getType()

    done it!!! ...its the same function call to getType() but on a line further down my code... i missed out the y in gateType(), but why would this affect the first call to that function also!!!!
    Last edited by bobthebullet990; 08-11-2006 at 03:21 PM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. can some one please tell me the cause of the error ?
    By broli86 in forum C Programming
    Replies: 8
    Last Post: 06-26-2008, 08:36 PM
  2. DirectInput help
    By Muphin in forum Game Programming
    Replies: 2
    Last Post: 09-10-2005, 11:52 AM
  3. Pong is completed!!!
    By Shamino in forum Game Programming
    Replies: 11
    Last Post: 05-26-2005, 10:50 AM
  4. string class errors
    By CodeMonkey in forum C++ Programming
    Replies: 13
    Last Post: 07-20-2003, 11:20 PM
  5. return values of functions
    By Granger9 in forum C Programming
    Replies: 3
    Last Post: 09-11-2002, 10:21 AM

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