用C ++错误创建一个类

时间:2012-12-15 19:55:37

标签: c++

我有一个测试类,除了类的骨头外,它没有任何内容。

H:

#ifndef TEST_H_
#define TEST_H_


class Test
{
public:
    Test();
};

#endif /* TEST_H_ */

CPP

#include "test.h"

Test::Test()
{
}

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

Test *test = new Test();

我还包括test.h。

我收到错误:

 Undefined reference to Test::Test()

谁能告诉我哪里出错?

1 个答案:

答案 0 :(得分:0)

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