Reputation: 435
I don't understand where is error... It gives me: error: expected ')' before 'conf' when I build...
This is generic.cpp file.
#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 << "\n\n";
std::cout << "Matched value: " << value << "\n\n";
int_param.name=name;
int_param.value=value;
this->conf.ints.push_back(int_param);
return value;
}
Here there is generic.h file:
#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
I also tried to put dynamic_reconfigure::Config conf as public but nothing. Can you help me?
Upvotes: 0
Views: 239
Reputation: 187
First of all, help us help you by pasting the compiler's output - or at least the line regarding the specific error you encounter (including the line of code causing this error).
Secondly, it's not advised to #include <string>
or any other include for that matter in the header file. see https://stackoverflow.com/a/553869/1778249 for when its useful.
Upvotes: -1
Reputation: 11058
You need to define your constructor properly, with class specification:
Generic::Generic(dynamic_reconfigure::Config conf)
^^^^^^^
Upvotes: 1
Reputation: 1582
Your constructor definition is Generic
in your code, you need Generic::Generic
Upvotes: 1
Reputation: 1078
The constructor is a member of the class, and when you define a member outside of the class definition you need to specify the class name and then the member name, like
Generic::Generic(dynamic_reconfigure::Config conf ) //Costruttore
^^^^^^^ ^^^^^^^
class member
Upvotes: 5