Thread: casting

  1. #1
    Registered User
    Join Date
    Aug 2005


    My specific question is: how do I fix this problem:

    if(whitepiece[index].jumpup(xposition2, yposition2, matrix) == 0 && whitepiece[index].moveup(xposition2, yposition2, matrix == 0))
    C:\PROGRAM FILES\MICROSOFT VISUAL STUDIO\MYPROJECTS\SnSCheckers\main.cpp(173) : error C2664: 'moveup' : cannot convert parameter 3 from 'bool' to 'int [][8]'
            Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast
    the .moveup and .jumpup functions return a bool and the matrix is [int][int].

    And in general, when does one need to typecast?

  2. #2
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Generally that sort of an error, pointer to integer, or integer to pointer, means you're passing the wrong thing to a function. Specifically, it means where you're supposed to be using an integer, you're using a pointer. In this case, it means you're doing something like this:
    void foo( int bar[][SOMESIZE] );
    int x;
    foo( x );
    This is clearly wrong, because this function wants a two dimensional array, and you're simply passing it one integer. A cast would most definately be wrong here. The correct thing to do would be to pass it what it expects you to pass it, and not something incorrect.

    Hope is the first step on the road to disappointment.

  3. #3
    Registered User
    Join Date
    Aug 2005
    caught my mistake, I just had a misplaced )

    so I <i>was</i> passing it the right data type...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Casting
    By morvick in forum C++ Programming
    Replies: 2
    Last Post: 06-17-2007, 11:06 PM
  2. Casting Question (I think)
    By fayte in forum C Programming
    Replies: 6
    Last Post: 03-08-2006, 05:31 PM
  3. casting the system exstracted date into seperate ints
    By bazzano in forum C Programming
    Replies: 1
    Last Post: 08-30-2005, 12:17 AM
  4. Type casting
    By Lionmane in forum C Programming
    Replies: 28
    Last Post: 08-20-2005, 02:16 PM
  5. question about casting pointers/other types also??
    By newbie02 in forum C++ Programming
    Replies: 3
    Last Post: 08-07-2003, 05:01 AM