inline const function doesnt compile

This is a discussion on inline const function doesnt compile within the C++ Programming forums, part of the General Programming Boards category; The following doesnt compile in VC2005 and I dont understand why. It says "cannot convert this pointer from const Sprite ...

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    330

    inline const function doesnt compile

    The following doesnt compile in VC2005 and I dont understand why.

    It says "cannot convert this pointer from const Sprite to Sprite &"

    All code is in the header and if I move GetXPos to .cpp it does compile but I would like to know why it doesnt when everything is in the header.



    Code:
    // sprite.h
    class X
    {
      bool GetXPos() const;
    
    private:
      Sprite array[10];
    };
    
    inline bool X::GetXPos(point p) const
    {
      return array[BUTTON_IMAGE].GetXPos(); // also const
    }

  2. #2
    The larch
    Join Date
    May 2006
    Posts
    3,573
    In one place it takes a point, in the other place it doesn't?
    I might be wrong.

    Thank you, anon. You sure know how to recognize different types of trees from quite a long way away.
    Quoted more than 1000 times (I hope).

  3. #3
    Registered User
    Join Date
    Jan 2007
    Posts
    330
    Quote Originally Posted by anon View Post
    In one place it takes a point, in the other place it doesn't?
    bleh forgot to remove the point in the example.
    problem is fixed it had nothing to do with C++ itself. There were 2 header files with same name

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Compiling sample DarkGDK Program
    By Phyxashun in forum Game Programming
    Replies: 6
    Last Post: 01-27-2009, 03:07 AM
  2. Dikumud
    By maxorator in forum C++ Programming
    Replies: 1
    Last Post: 10-01-2005, 07:39 AM
  3. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 06:59 AM
  4. structure vs class
    By sana in forum C++ Programming
    Replies: 13
    Last Post: 12-02-2002, 07:18 AM
  5. Interface Question
    By smog890 in forum C Programming
    Replies: 11
    Last Post: 06-03-2002, 06:06 PM

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