Class Variable = Error?

This is a discussion on Class Variable = Error? within the C++ Programming forums, part of the General Programming Boards category; Code: UseDriver _Driver; bool main(){ BYTE _Buffer[] = { 0xE9, 0xAB, 0x02, 0x00, 0x00 }; BYTE * pBuffer = _Buffer; ...

  1. #1
    Registered User
    Join Date
    Dec 2001
    Posts
    206

    Class Variable = Error?

    Code:
    UseDriver _Driver;
     
    bool main(){
     
            BYTE _Buffer[] = { 0xE9, 0xAB, 0x02, 0x00, 0x00 };
            BYTE * pBuffer = _Buffer;
    
            //Unrelated junk.
     
            if(!_Driver.Detour((pBuffer, sizeof(_Buffer)))
                    return false;
     
            return true;
    }
     
    class UseDriver
    {
    public:
            bool Detour(BYTE * Buffer, int Size);
            //Unrelated junk
     
    private:
            char _Buffer[300];
            bool PtB(BYTE * Buffer, int Size);
            //Unrelated junk
    };
     
    bool UseDriver::Detour(BYTE * Buffer, int Size)
    {
            PtB(Buffer, Size);
    
            //Unrelated junk
     
            return true;
    }
    bool UseDriver::PtB(BYTE * Buffer, int Size)
    {
            for(int i = 0; i < Size; i++)
                    _Buffer[i] = Buffer[i];
     
            return true;
    }
    The operation in PtB() crashes my program.
    Last edited by Denethor2000; 11-09-2005 at 10:04 PM.

  2. #2
    Registered User
    Join Date
    Apr 2003
    Posts
    2,662
    Is size larger than 300? Is size larger than the size of Buffer? What's a BYTE?

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    7,325
    A BYTE is (usually) a typedef for unsigned char.

    That code shouldn't compile, there is an extra parenthesis in your call to Detour. If you fix that, it compiles and runs without a crash, so your problem is probably in the unrelated junk.

    Identifiers that start with an underscore followed by a capital letter are reserved, so you shouldn't be putting the underscore at the front of your variable names in case they clash with implementation macros. Also, main must specify int as its return value, not bool.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Another syntax error
    By caldeira in forum C Programming
    Replies: 31
    Last Post: 09-05-2008, 01:01 AM
  2. Please Help - Problem with Compilers
    By toonlover in forum C++ Programming
    Replies: 5
    Last Post: 07-23-2005, 10:03 AM
  3. pointer to array of objects of struct
    By undisputed007 in forum C++ Programming
    Replies: 12
    Last Post: 03-02-2004, 03:49 AM
  4. Couple C questions :)
    By Divx in forum C Programming
    Replies: 5
    Last Post: 01-28-2003, 12:10 AM
  5. Linking error
    By DockyD in forum C++ Programming
    Replies: 10
    Last Post: 01-20-2003, 04:27 AM

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