I'm trying to determine the difference between two ways to expose a constructor when you're using private inheritance under C++11.
Method 1:
class Base {
public:
int i;
Base(int x): i(x) {}
};
class Derived : private Base {
public:
Derived(int x) : Base(x) {} // constructor method 1
};
Method 2:
class Base {
public:
int i;
Base(int x): i(x) {}
};
class Derived : private Base {
public:
using Base::Base; // constructor method 2
};
In superficial tests, both seem to work the same. The only real difference is that my code editor (clion) doesn't seem to like the latter. Is there more to the story here? Are either of these clearly preferable?