16

Now this is a weird problem. I was coding two days ago and stopped and then continued just now. On my header file (Fruit.h) I added a method called animateGrow() like so:

Fruit.h:

class Fruit {
private:
   // Member variables here

public:
   // Other methods here
   void animateGrow( );
};

But when I try to add the same method in the CPP file, I get an Out-of-line definition of 'animateGrow' does not match any declaration in 'Fruit' error. It's declared in the header but Xcode does not seem to be able to find that method.

Fruit.cpp:

#include "SimpleAudioEngine.h"
#include "Fruit.h"
#include "Tree.h"

using namespace cocos2d;
using namespace CocosDenshion;

Fruit::Fruit( ) {
   // Constructor
}

// Getter Methods
// Setter Methods
// Other Methods

void Fruit::animateGrow( ) {
   // I get an error here when I type it.
}

Full Code: (links removed) (In the code, the Tree class exists and all other methods and functions are working fine except for the animateGrow() as it gives me the error)

alxcyl
  • 2,722
  • 7
  • 31
  • 47
  • You should close the question, as its usefulness for future users is limited to none. Glad you fixed it, and good luck. – David Rodríguez - dribeas Aug 09 '12 at 03:55
  • @DavidRodríguez-dribeas How do I close a question? Sorry, I'm not familiar with this. – alxcyl Aug 09 '12 at 03:56
  • Uhm... is there not a link below the tags? (It might be that you need some reputation to do that... if the link is not there, don't worry, someone else will close it --I already voted to close, it just needs a couple more votes :) – David Rodríguez - dribeas Aug 09 '12 at 03:58
  • @DavidRodríguez-dribeas Oh, there's no close link, just share, edit, delete, and flag. Thanks :) – alxcyl Aug 09 '12 at 04:01
  • 3
    I disagree - I came here today looking for a solution to the exact same error message, and there are 6 upvotes on this question. Propose it is re-opened. – aaronsnoswell Jan 08 '14 at 23:20
  • I bumped into this exact problem when renaming class and header files (decided to cvt. objC to cpp rather than wrapping). I couldn't figure out what was going on since my header file looked OK, but I got the error. Re-starting Xcode was all it took. This post saved me a lot of time! Thanks @Lance! – clearlight Jan 27 '14 at 18:23

1 Answers1

10

Fixed it.

I don't know why but Xcode did not save my changes on the header file. I closed Xcode and opened the header file and the changes aren't there. I added the methods again and saved. I opened the CPP file added the new method in it worked fine.

Really weird.

alxcyl
  • 2,722
  • 7
  • 31
  • 47