So i am trying to make class Bed inherit from class Device. I know the constructor is called with an int, Socket class and Ini class; the thing i dont know is whether or not more arguments are passed of different classes.
thats what im trying to do here in my Bed.cpp file:
#include "Bed.h"
#include <fstream>
#include <string>
#include <sstream>
#include <iostream>
#include <unistd.h>
#include <string>
#include <vector>
#include "Socket.h"
#include "Ini.h"
using namespace std;
class Socket;
class Ini;
template <typename... Types> Bed<Types...>::Bed(int number, Socket s, Ini i, const Types&... var): id(number), socket(s), ini(i) {
if (typeid(var).name() == "Button") {
buttons_.push_back(var);
} else if (typeid(var).name() == "Led") {
leds_.push_back(var);
} else if (typeid(var).name() == "RGBled") {
rgbleds_.push_back(var);
} else {
cout<<"error"<<endl;
}
}
template <typename... Types> void Bed<Types...>::check() {
for (int i = 0; i <= buttons_.size() - 1; i++) {
buttons_[i].getStatus();
}
getPressure();
}
template <typename... Types> void Bed<Types...>::getPressure() {
}
this is my Bed.h file:
#ifndef BED_H_
#define BED_H_
#include <string>
#include <vector>
#include <iostream>
#include <cstdarg>
using namespace std;
class Device;
class Socket;
class Ini;
template <typename... Types> class Bed: public Device {
public:
Bed(int, Socket, Ini, const Types...);
void getPressure();
void check();
private:
int pressureSensor = 0;
};
#endif
and this is my Device.h file:
#ifndef DEVICE_H_
#define DEVICE_H_
#include <string>
#include <vector>
#include <iostream>
#include <cstdarg>
using namespace std;
class Button;
class Led;
class RGBled;
class Socket;
class Ini;
template <typename... Types> class Device {
public:
//Device(int, Socket, Ini, const Types&...);
virtual void check();
//virtual ~Device();
private:
vector<Led> leds_;
vector<Button> buttons_;
vector<RGBled> rgbleds_;
Socket socket;
Ini ini;
int id;
};
#endif
In my Bed.cpp, I get the error
declaration is incompatible with "Bed::Bed(int, Socket, Ini, Types...)" (declared at line 17 of "/home/programmer/project/Bed.h")
which is the line
Bed(int, Socket, Ini, const Types...);
I've been trying to fix this for hours now, and at this point I've got no clue anymore.