类构造函数声明了两次
Class Constructor declared twice
在Arduino IDE中,我收到一个关于我的构造函数如何声明两次的错误。
这是它的代码:
托德·
#ifndef TOND_H
#define TOND_H
class Tondeuse {
public:
Tondeuse();
Tondeuse(int,int);
};
#endif
嘟嘟.cpp
#ifndef TOND
#define TOND
#include "arduino.h"
#include "tond.h"
Tondeuse::Tondeuse()
{
}
Tondeuse::Tondeuse(int h, int w)
{
Serial.println("Hello");
}
#endif
和错误:
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:11: multiple definition of `Tondeuse::Tondeuse()'
tond.cpp.o:C:UsersDEPANNEAppDataLocal Tempbuild6942484698459603114.tmp/tond.cpp:11: first defined here
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:11: multiple definition of `Tondeuse::Tondeuse()'
tond.cpp.o:C:UsersDEPANNEAppDataLocal Tempbuild6942484698459603114.tmp/tond.cpp:11: first defined here
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:16: multiple definition of `Tondeuse::Tondeuse(int, int)'
tond.cpp.o:C:UsersDEPANNEAppDataLocalTempbuild6942484698459603114.tmp/tond.cpp:16: first defined here
Tondeuse.cpp.o: In function `Tondeuse':
/tond.cpp:16: multiple definition of `Tondeuse::Tondeuse(int, int)'
tond.cpp.o:C:UsersDEPANNEAppDataLocalTempbuild6942484698459603114.tmp/tond.cpp:16: first defined here
我没有两次包含它,也找不到任何问题。
您在Tondeuse.cpp
中包含在tond.cpp
中。不要包含实现文件。
如果该文件不再存在(重构),请确保在重新生成之前清理解决方案。
相关文章:
- 用相同的参数声明两个构造函数的最偶像化的方法是什么?
- pair的两个构造函数几乎相同,为什么不生成构建错误?
- 为什么<T> LLVM 中的预期为 Expect&&... 实现两个构造函数<T>?
- 为什么我的类只适用于两个构造函数 C++
- 两个构造函数(带和不带参数),没有输入 -> 没有参数运行。跳过上述类中的构造函数
- 类介绍 (c++) 项目希望我们创建两个构造函数,但它们都不需要任何参数 - 我应该在这里做什么?
- 除了两个构造函数外,C++库导入也可以工作
- 两次构造对象
- 在两个构造函数之前将我的静态数据成员在 CPP 文件中初始化为 0
- 如何有条件地在具有相同签名的两个构造函数之间切换
- RAII 在两个构造函数之间进行选择的方式
- 调用对数组引用两次的函数
- std::make_shared在VS2012中进行了两次构造函数调用
- 具有两个构造函数的抽象类
- 如何在c++中实现二次构造函数
- 这两个构造函数调用之间的区别
- 为什么在我的程序中调用两个构造函数
- 组合复制和移动的两个构造函数
- 为什么这两个构造函数一起不会产生歧义错误?
- C++两次传递函数指针导致问题