C++ has a templates for this:
template<typename T>
class MyClass
{
T* s;
MyClass(){
s = new T(); //the only practical difference
...
}
void method()
{
...
//this is simplification, in reality the code is more complex
//however the same as in class_2
inner_data += s->s1;
inner_data += s->s2;
inner_data += s->s3;
...
}
//other methods
};
Now you can use your classes as:
MyClass<struct_1> a;
and
MyClass<struct_2> b;
and compiler will generate definitions for these classes based on your template.
Don't forget to deallocate memory in your destructor!