If the code that you expect to go where you write
//stuf...
is simple, duplicate the code.
If not, create a function and call the function.
Example (Simple)
Duplicate the code.
class Foo1 {
public:
Foo1(int a, int b) { int i = 0; int j = 0; }
}
class Foo2 {
Foo1 foo1(2, 1);
public:
Foo2(int a, int b) { int i = 0; int j = 0; }
}
Example (Not Simple)
Use a function.
int complexFunction() { ... }
class Foo1 {
public:
Foo1(int a, int b) { int i = complexFunction(); }
}
class Foo2 {
Foo1 foo1(2, 1);
public:
Foo2(int a, int b) { int i = complexFunction(); }
}