Thread: inline const function doesnt compile

  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, 06:39 AM
  3. How do i un-SHA1 hash something..
    By willc0de4food in forum C Programming
    Replies: 4
    Last Post: 09-14-2005, 05: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, 05:06 PM