I am getting an error for no reason

It is saying "Member declaration not found" in Word.cpp, "undefined reference to `WinMain@16'" in Word, and "recipe for target 'Word' failed" in makefile. But the code is PERFECTLY FINE. What do I have to change?

Word.cpp:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string>
#include "Word.h"
#include <iostream>

using namespace std;

Word::Word() {
	word = "";
}

string Word::getWord(){
	return word;
}

void Word::setWord(string w) {
	word = w;
}


Word.h:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <string>
#ifndef WORD_H_
#define WORD_H_

class Word
{
private:
	std::string word;

public:
	Word();
	std::string getWord() const;
	void setWord(std::string);
};

#endif
Last edited on
Where's People.cpp (and presumably People.h)?
I actually meant Word.cpp and Word.h. I fixed it.
Last edited on
"undefined reference to `WinMain@16'"


I am not a windows guy, but did you start a windows project, then put ordinary code in the files? Try to start a blank project.
The Word::getWord() declared in Word.h is const, but the one defined in Word.cpp is non-const. Either make both const or both non-const.
As for the undefined reference, I'd guess you didn't define a main() function anywhere.
Last edited on
Topic archived. No new replies allowed.