<分区>
所以我昨天才开始真正地学习 C++,并且由于之前使用 Lua 的一些经验,我很快就掌握了。我一直在 http://courses.caveofprogramming.com/ 开设初学者类(class)。 .我试图创建一个类,但遇到了错误。可能还值得一提的是,专家使用 Eclipse 作为他的 EDI,而我使用 CodeBlocks。这是我的。
主要.cpp
#include <iostream>
#include "Cat.h"
using namespace std;
int main()
{
Cat tommy;
tommy.Grizzly() == true;
tommy.Bark();
return 0;
}
猫.cpp
#include "Cat.h"
#include <iostream>
using namespace std;
void Cat::Bark()
{
if (Grizzly())
{
cout << "RUFF!!!!!!" << endl;
}
else
{
cout << ":)" << endl;
}
}
目录.h
#ifndef CAT_H
#define CAT_H
class Cat
{
public :
bool Grizzly();
void Bark();
};
#endif // CAT_H
这里是错误
C:\Users\Nas\Desktop\Coding Projects\Class Members 4\main.cpp|9|undefined reference to `Cat::Grizzly()'|