C++ --> 错误:'conf'之前的预期')'
C++ --> error: expected ')' before 'conf'
我不明白错误在哪里...它给了我:错误:当我构建时,在"conf"之前预期")"...
这是通用.cpp文件。
#include <stdio.h>
#include "generic.h"
#include <string>
#include <iostream>
Generic(dynamic_reconfigure::Config conf ) //Costruttore
{
this->conf = conf;
}
int Generic::addInt(std::string name, int value)
{
dynamic_reconfigure::IntParameter int_param;
std::cout << "Insert an integer value of " << name << ":n";
std::cin >> value;
std::cout << "Setting " << name << "nn";
std::cout << "Matched value: " << value << "nn";
int_param.name=name;
int_param.value=value;
this->conf.ints.push_back(int_param);
return value;
}
这里有 generic.h 文件:
#ifndef GENERIC_H_INCLUDED
#define GENERIC_H_INCLUDED
#include <string>
#include <dynamic_reconfigure/IntParameter.h>
#include <dynamic_reconfigure/Config.h>
class Generic{
dynamic_reconfigure::Config conf;
public:
Generic(dynamic_reconfigure::Config conf ); //Costruttore
int addInt(std::string name, int value);
};
#endif // GENERIC_H_INCLUDED
我还尝试将dynamic_reconfigure::Config conf作为公共的,但没有。你可以帮我吗?
构造函数是类的成员,当您在类定义之外定义成员时,您需要指定类名,然后指定成员名,例如
Generic::Generic(dynamic_reconfigure::Config conf ) //Costruttore
^^^^^^^ ^^^^^^^
class member
你的构造函数定义在你的代码中Generic
,你需要Generic::Generic
你需要用类规范正确定义构造函数:
Generic::Generic(dynamic_reconfigure::Config conf)
^^^^^^^
首先,通过粘贴编译器的输出来帮助我们帮助您 - 或者至少粘贴有关您遇到的特定错误的行(包括导致此错误的代码行)。
其次,不建议在头文件中#include <string>
或任何其他包含。 请参阅 https://stackoverflow.com/a/553869/1778249 了解何时有用。
相关文章:
- 警告处理为错误这里有什么问题
- "error: no matching function for call to"构造函数错误
- boost::进程间消息队列引发错误
- C++,OpenCV,尝试显示图像时"OpenCV(4.3.0) Error: Assertion failed (size.width>0 && size.height>0)"此错误
- 有关插入适配器的错误。[错误]请求从 'back_insert_iterator<vector<>>' 类型转换为非标量类型
- QT在错误的班级中寻找空位
- vector.resize()中的分配错误
- 代码在main()中运行,但在函数中出现错误
- 释放错误后堆使用
- (C++)分析树以计算返回错误值的简单算术表达式
- Project Euler问题4的错误解决方案
- 我的字符计数代码计算错误.为什么
- 从"int*"强制转换为"unsigned int"会丢失精度错误
- 尝试导入pybind-opencv模块时出现libgtk错误
- CMake项目Boost库错误:Boost/config/compiler/gcc.hpp:165:10:致命错误:cs
- 在某些循环内使用vector.push_back时出现分段错误
- MSVC多行宏编译器错误
- 静态数据成员的问题-修复链接错误会导致编译器错误
- 无法找到/读取配置文件.conf-FileIOException
- C++ --> 错误:'conf'之前的预期')'