1
template<typename Type, size_t Dimensions> 
struct Base 
{  
     template <typename ... Args>
    Base (const Args& ... args) : /*initialize*/ {}
/*
some functionality
*/
};

template<size_t Dimensions>
using myBase = typename Base<_DOUBLE,Dimensions> ;

template<size_t Dimensions> 
class Derived: public myBase<Dimensions> 
{
/*
some additional functionality
*/
}

myBase<2> mB(1.0,2.0); //works
Derived<2> D(1.0,2.0); //error C2661: 'Derived<2>::Derived': no overloaded function takes 2 arguments

Why the implicit inheritance of the constructor doesn't work and if it is necessary, how to create the correct constructor in this case?

1 Answer 1

3

No need of typename here:

using myBase = typename Base<_DOUBLE,Dimensions> ;

Constructors are not inherited unless explicitely specified with using keyword (see Inheriting constructors).

template<size_t Dimensions> 
class Derived: public myBase<Dimensions> 
{
public:
    using myBase<Dimensions>::myBase;
};    
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.