According to the answers I got here , the code below is poorly formed, despite the fact that clang and vs2015 accept it.
#include <iostream> class A { public: A() { std::cout << "A()" << '\n'; } }; int main() { A::A(); }
However, the code below works in all 3 compilers (see live example ). AFAICT, according to [class.qual / 2], the code is poorly formed. Or am I missing something here?
Furthermore, according to [class.qual] / 2, the code below is well-formed, in which case all 3 compilers produce the expected result (see example here ).
include <iostream> struct B { B() { std::cout << "B()" << '\n'; } }; struct A : public B { using B::B; A() { std::cout << "A()" << '\n'; } void f() { B(); } }; int main() { A a; af(); }
Output:
B() A() B()
But I would like to know what is the use of using a declaration calling the constructor as one ( using B::B; ) in class A above. Note that this use-declaration is completely irrelevant in this case, whether B base class of A or not.
source share