I have a virtual function in a base class, taking a parent struct as an argument:
class Parent
{
struct foo_t {...};
virtual void set_foo(foo_t &foo) = 0;
};
which I want to override in a derived class, using a child struct:
class Child : public Parent
{
typedef struct bar_t : Parent::foo_t
{
...
} bar_t __attribute__((packed));
bar_t y{};
void set_foo(bar_t &x) override { y = x };
};
When I compile like this, I get the error marked 'override' but does not override
as the virtual function has a different argument type.
If I change the override to set_foo(foo_t &x) override { y = x };
it doesn't compile as I'm trying to assign a parent struct to a child.
If I then change the assignment to static_cast<foo_t>(&y) == x
I get expression must be a modifiable lvalue
.
Or if I change the assignment to y = (bar_t*)(&x)
it doesn't compile as I'm trying to assign a pointer to a struct.
How to go about this?