在错误中创建类C++

Creating a class in C++ error

本文关键字:C++ 创建 错误      更新时间:2023-10-16

我有一个测试类,除了类的骨头之外,它什么都没有。

h:

#ifndef TEST_H_
#define TEST_H_

class Test
{
public:
    Test();
};
#endif /* TEST_H_ */

.cpp

#include "test.h"
Test::Test()
{
}

然后在我的主要课程中,我有:

Test *test = new Test();

我还包括测试。

我收到错误:

 Undefined reference to Test::Test()

谁能告诉我哪里出错了?

通了,即使在清理项目并重新启动IDE之后,它仍然无法正常工作。我不得不手动将test.h和test.cpp添加到我的config.pri中