I'm looking through some legacy code and I've come across a case where the developer has 'extended' an existing class with additional members, using inheritance as his weapon of choice. Essentially it reduces to something like this:

```
struct A
{
    int something_old;
};

struct B : public A
{
    int something_new;
};

```

There's a section of code where they have an instance of A, but actually want an instance of B. Here's how they managed to achieve it:

```
auto aa = GetAn_A(); // for example
   :
B bb;
*(A*)&bb = aa; // <-- code smell?
bb.something_new = 42;

```

This seems to work ok: it slices bb and then assigns to the sliced part. But I can't help but thinking that in these enlightened C++ days, that all of that hacking 'n' slicing with &'s and \*'s is a bit old school.

**Is there a code smell here and, if so, how big of a smell? Should could like this still need to be written?**

If it *is* smelly, where did the author start to lose the plot, and what could/should they have done to get the result they wanted, i.e. an extension to a existing class (bearing in mind that A and B are significantly more complicated than this in reality, and that A was written some time before B)?