B
Belebele
I would like to have the compiler bind a Base class const reference to
a temporary object of a Derived class when calling another class
constructor. Please see the code below:
class Base {};
class Derived: public Base {};
class Foo {
public:
Foo(Base const& );
void bar();
};
int main()
{
Foo foo(Derived());
foo.bar();
}
One compiler gives me the following error:
error: expression must have class type foo.bar();
Another compiler also complains:
error: request for member `bar' in `foo', which is of non-aggregate
type `Foo ()(Derived (*)())'
Any idea why?
a temporary object of a Derived class when calling another class
constructor. Please see the code below:
class Base {};
class Derived: public Base {};
class Foo {
public:
Foo(Base const& );
void bar();
};
int main()
{
Foo foo(Derived());
foo.bar();
}
One compiler gives me the following error:
error: expression must have class type foo.bar();
Another compiler also complains:
error: request for member `bar' in `foo', which is of non-aggregate
type `Foo ()(Derived (*)())'
Any idea why?