Hi can you please help me

David Fang fang@csl.cornell.edu
Sun Feb 25 01:39:00 GMT 2007


> I am making a C++ program but i got some problem here.
> I have one header file and one source file Slover.hpp and Slover.cpp
>
> the content of the Slover.hpp is
>
> #ifndef SLOVER_HPP_
> #define SLOVER_HPP_
> #include <iostream>
> #include <cstdlib>
> #include <ctime>
> #include <math.h>
> #include <iomanip>
> #include <string>
> #include <vector>
>
> using namespace std;
>
> #include "Game.hpp"
>
> class Slover{
> 	private:
> 		typedef struct Guess {
> 			vector <char> guessPuzzle;
> 			int CorrectPosition;
> 			int CorrectColor;
> 		};
>
> 		vector <Guess> guesses;
> 	public:
> 		Slover();
> 		~Slover();
> 		bool Guess (const Game* game, Guess  &guessPuzzle);
>
>
> };
>
> and the Slover.cpp file is:
>
> using namespace std;
> #include "Slover.hpp"
>
> 	Slover(){
> 	}

// Did you mean: (You forgot the class name.)

Slover::Slover() { }

> 	~Slover(){
> 	}

Slover::~Slover() { }

> 	bool Slover::Guess (const Game* game, Guess &guessPuzzle){
>                //do something here
> 	return true;
>
> I got the error message:
> error: prototype for `bool Slover::Guess(const Game*, int&)' does not match
> any in class `Slover'

Again, you forgot the full class name before the constructor:

bool
Slover::Guess::Guess(...) {
}

> Can you please tell me what mistake that i have made there? And how can i
> fix this? I am quite new to C++ so please forgive if the question is not
> appropriate.

Fang




More information about the Gcc-help mailing list