Error: declaration is incompatible with...

Hi everyone, I'm writing a function definition for my header file and I can't get rid of this "declaration is incompatible with" error.
This is my header:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#ifndef _HAND_H
#define _HAND_H

#include "card.h"

const int HANDSIZE = 5;

class Hand {
	private:
		Card hand[HANDSIZE];
	public:
		Hand();
		void checkFlush(Card::Suit, int);
		void checkPair(Card::Value, int);
};


#endif 


And the .cpp file:

1
2
3
4
5
6
7
8
9
10
11
#include <stdlib.h>
#include "hand.h"
#include "card.h"

void Hand::checkFlush (Card::Suit arr[5], int &f) {
	if (arr[0] == arr[1] &&	
	    arr[0] == arr[2] &&
	    arr[0] == arr[3] &&
	    arr[0] == arr[4])
	    f++;
}


The error appears in the .cpp file at "checkFlush". I found a post with a similar problem, and they concluded that this was because one of their arguments wasn't declared (I'm guessing Card::Suit arr[5] in my case). I'm just wondering where I'm supposed to declare this?

Thanks for any help you can give me!
-Ryan
The types of the parameters are not the same in the header as in the source file.
Last edited on
I don't see how they're different...They both have the types Card::Suit and int don't they? I'm sorry if this is a stupid question, I've always been kind of confused with function arguments
No. Your prototype has those types. Your implementation uses different types.

Your prototype takes one Card::Suit object by value. The actual implementation takes a pointer to Card::Suit. The prototype takes an int by value, the actual implementation takes an int by reference.

1
2
3
		void checkFlush(Card::Suit[], int&)
		void checkFlush(Card::Suit[5], int&);
		void checkFlush(Card::Suit*, int&);



would be valid prototypes with the same argument types.
Ahh, alright thanks a lot! I always get confused with pointers in these sorts of situations. I guess I just need to practice more.
Thanks again
Topic archived. No new replies allowed.