Answer the question
In order to leave comments, you need to log in
How to use a pure virtual method inside a class?
I'm trying to define the parent class:
#ifndef OBJECT_H
#define OBJECT_H
#include <sstream>
#include <string>
class Object
{
private :
virtual void fillBufferForPrint(std::ostringstream &strs) = 0;
public:
Object();
operator std::string();
};
#endif // OBJECT_H
#include "object.h"
Object::Object()
{
}
Object::operator std::string() {
std::ostringstream s;
fillBufferForPrint(&s);
return s.str();
}
***/object.cpp:10: error: no matching function for call to 'Object::fillBufferForPrint(std::ostringstream*)'
fillBufferForPrint(&s);
^
Answer the question
In order to leave comments, you need to log in
In the declaration, the method takes a reference, and you pass in a pointer.
fillBufferForPrint(&s); // Нужно не так.
fillBufferForPrint(s); // А так.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question