fork download
  1. #include <iostream>
  2.  
  3. class Base
  4. {
  5. protected:
  6. template<typename ...Args>
  7. Base(Args ...args)
  8. {
  9. std::cout << "variadic ctor" << std::endl;
  10. }
  11.  
  12. template<typename T>
  13. Base(T t)
  14. {
  15. std::cout << "template ctor" << std::endl;
  16. }
  17.  
  18. Base(char const *s)
  19. {
  20. std::cout << s << std::endl;
  21. }
  22. };
  23.  
  24. class Derived : public Base
  25. {
  26. protected:
  27. using Base::Base;
  28. };
  29.  
  30. int main(int, char**) noexcept
  31. {
  32. //Base bv{ 0, 1 }; // error: 'Base::Base(Args ...) [with Args = {int, int}]' is protected within this context
  33. //Base bt{ 0 }; // error: 'Base::Base(T) [with T = int]' is protected within this context
  34. //Base bs{ "base" }; // error: 'Base::Base(const char*)' is protected within this context
  35. Derived dv{ 0, 1 };
  36. Derived dt{ 0 };
  37. //Derived ds{ "derived" }; // error: 'Derived::Derived(const char*)' is protected within this context
  38. return 0;
  39. }
  40.  
Success #stdin #stdout 0s 15240KB
stdin
Standard input is empty
stdout
variadic ctor
template ctor