I noticed this when trying out the optional references:
#include "Optional/optional.hpp"
using std::experimental::optional;
class foo {
virtual void doSomething() = 0;
};
class bar : public foo {
void doSomething() override {
}
};
int main() {
// This works...
int i = 3;
int & ir = i;
optional<int &> oir = ir;
// And so does this...
bar b;
foo & fr = b;
bar & br = b;
optional<bar &> obr = br;
// But this does not...
optional<foo &> ofr = fr;
}
The error that comes up is:
cannot allocate an object of abstract type ‘foo’ because the following virtual functions are pure within ‘foo’: virtual void foo::doSomething()
One is able to have raw references to an abstract type. So it would seem that an optional reference could be had to an abstract type as well?
I noticed this when trying out the optional references:
The error that comes up is:
One is able to have raw references to an abstract type. So it would seem that an optional reference could be had to an abstract type as well?