Thread: reinterpret_cast, C-style cast or function-style cast

  1. #1
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266

    reinterpret_cast, C-style cast or function-style cast

    hey all, hope everyone is doing well

    i don't quite understand why i'm getting the error mentioned in the subject line. here's the member function call and definition:
    Code:
    Player *p_batter=mf_lineup_getBatter();
    //member function call and assignation
    // . . . 
    Player* Lineup::mf_lineup_getBatter()
    {
    	static int x=0;
    	return (lineup[x]);
    }
    //defination, Player* is pointing to separate class instance
    here's the error message:

    :\MPROG\sandlot\game.cpp(24) : error C2065: 'mf_lineup_getBatter' : undeclared identifier
    C:\MPROG\sandlot\game.cpp(24) : error C2440: 'initializing' : cannot convert from 'int' to 'class Player *'
    Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast


    does my error have something to do with the array subscript?

    thanks for your help

  2. #2
    Registered User matheo917's Avatar
    Join Date
    Sep 2001
    Posts
    279
    try this:

    replace the line:

    return (lineup[x]);

    with:

    return this[x];


    i didn't compile it but it should work....



    ps. it seams like the problem is in the return values....in terms of a pointer to an object and static members....



    Regards,
    matheo917

  3. #3
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    tried that already, thanks though

  4. #4
    Registered User blight2c's Avatar
    Join Date
    Mar 2002
    Posts
    266
    i got it. it was such a stupid mistake i'm not gonna let anyone know what it was. thanks for looking though

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Screwy Linker Error - VC2005
    By Tonto in forum C++ Programming
    Replies: 5
    Last Post: 06-19-2007, 02:39 PM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. Tab Controls - API
    By -KEN- in forum Windows Programming
    Replies: 7
    Last Post: 06-02-2002, 09:44 AM
  4. errors in class(urgent )
    By ayesha in forum C++ Programming
    Replies: 1
    Last Post: 11-10-2001, 10:14 PM
  5. errors in class(urgent)
    By ayesha in forum C++ Programming
    Replies: 2
    Last Post: 11-10-2001, 06:51 PM