Whenever I try to run my program with the following class, I get an error linked to the declaration of std::stringstream newPredicate; As soon as I remove that declaration (and any uses of it in the source code), the error goes away.
#ifndef LAB1_PREDICATE_H
#define LAB1_PREDICATE_H
#include <sstream>
class Predicate {
private:
public:
std::stringstream newPredicate;
void addToString(std::string tokenValue);
void clearString();
std::string toString();
};
#endif //LAB1_PREDICATE_H
Below is the source code for the header. I have the stringstream set as a class member so I can access it through any of the functions.
#include "Predicate.h"
void Predicate::addToString(std::string tokenValue) {
newPredicate << tokenValue;
}
void Predicate::clearString() {
newPredicate.clear();
}
std::string Predicate::toString() {
std::string predicateString;
newPredicate >> predicateString;
return predicateString;
}
I have a call to a Predicate object a number of times in another class. After I've filled it with the wanted string values, I push it into a vector and clear it.
std::vector<Predicate> myVector;
Predicate myPredicate;
myPredicate.addToString(myString); //I call this function a few times
myVector.push_back(myPredicate);
myPredicate.clearString();
Here's the error message
error: use of deleted function 'Predicate::Predicate(const Predicate&)'
{ ::new((void *)__p) _Up(std::forward<_Args>(__args)...); }
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
And then a note
note: 'Predicate::Predicate(const Predicate&)' is implicitly deleted because
the default definition would be ill-formed:
class Predicate {
^~~~~~~~~