Very new to C++. I'm having trouble including a class and function from my header file into my cpp file. I've double checked everything and can't figure out what I'm doing wrong, maybe the format for eclipse is different from the guide I am following? If anyone can help it's very appreciated I've been stuck on this for a while.
I'm using the latest versions of Eclipse Indigo for C++ and MinGW
Below are my cpp and h files:
This is my .cpp file
#include <iostream>
#include "helloworldmodularized2.h"
using namespace std;
int main()
{
cat Earth;
Earth.door_greeting();
}
Here is the .h file I am trying to include into my .cpp file
//helloworldmodularized2.h
#include <iostream>
using namespace std;
class cat
{
public:
void door_greeting();
};
void cat::door_greeting()
{
cout << "Hello World!\n";
cout << "Hello Door!\n";
cout << "Hello Cat!\n";
}
The .h file presents no errors
The errors I am getting when trying to build the .cpp file are:
'cat' was not declared in this scope Line 11
'Earth' was not declared in this scope Line 12
The code looks fine. Make sure the .h and .cpp are in the same directory.
Goto project properties
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.