'未定义参考'当试图访问另一个文件中的类时

时间:2015-05-23 21:47:31

标签: c++

所以基本上我正在制作这个简单的程序来添加数字,但不断得到错误&未定义引用tent :: boom'。几个小时我一直在修补代码并查看了许多不同的解决方案,但它们似乎都没有用于任何理由,所以如果之前已经问过这个问题的类似版本,我很抱歉。

//main.cpp
#include <iostream>
#include "tent.h"


using namespace std;


int main()
{
    tent bo;
    bo.boom();

    return 0;
}

//tent.h
#include <iostream>

class tent
{
public:
    tent();
    int boom();

protected:
private:
};

//tent.cpp
#include "tent.h"
#include <iostream>


using namespace std;

int boom()
{
    int a;
    int b;
    int c = a + b;
    cin >> a;
    cin >> b;
    cout << c << endl;
    return 0;
}

1 个答案:

答案 0 :(得分:-1)

我所做的是将tent.cpp的繁荣改为帐篷::繁荣