【发布时间】:2014-11-28 12:45:24
【问题描述】:
我在以下代码中的字符串class AInv { 上收到消息:undefined reference to AVector::AVector():
#ifndef AINV_HPP_
#define AINV_HPP_
#include "AVector.hpp"
class AInv {
public:
double w;
double g;
AVector vector;
};
#endif /* AINV_HPP_ */
AVector的定义:
#ifndef AVECTOR_HPP_
#define AVECTOR_HPP_
class AVector {
public:
double x;
double y;
double z;
AVector();
AVector(const AVector &v);
};
#endif /* AVECTOR_HPP_ */
是否可以使用类变量(不是地址)作为类成员?我想避免变量向量的显式构造函数/析构函数。
【问题讨论】:
-
错误
undefined reference是链接错误。您可能没有AVector的默认构造函数的定义,或者它没有被链接到 -
感谢尼尔!我确实跳过了makefile中的AVector.o。问题解决了!