I want to make a behavior like std::cout
has:
int a = 10, b = 15, c = 7;
MyBaseClass << "a = " << a << ", b = " << b << std::endl;
I try to implement some things which I've just read but it doesn't work for me. I want to implement operator
in one class which I call MyBaseClass
. I tried this:
class MyBaseClass {
private:
std::ostream someOut;
public:
// My first try:
std::ostream &operator<< ( std::ostream &out, const std::string &message ) {
}
// The second try:
std::ostream &operator<< ( const std::string &message ) {
someOut << message << std::endl;
return someOut;
}
void writeMyOut() {
std::cout << someOut.str()
};
};
When I compile this I get: "Call to implicity-deleted default constructor of 'MyBaseClass'" - what do I need to do to fix it?
OS X, Xcode, clang compiler, all is up-to-date.