www.digitalmars.com         C & C++   DMDScript  

c++ - initialization of array of template class

Here is a test-case:

template<class T>
struct A
{
  A(T a, T b)
    : a_(a), b_(b)
  { }

  T a_, b_;
};

int main(int argc, char *argv[])
{
  A<int> a[] = {
    A<int>(3, 6)
    // Error: need explict cast to convert
    // from: A<int >
    // to  : int 
  };

  return a[0].a_ + a[0].b_ - 9;
}


BTW, it works if I use a non-template class instead of the template class.


bye, Christof

-- 
http://cmeerw.cjb.net                          Jabber: cmeerw jabber.at
mailto cmeerw at web.de                   ICQ: 93773535, Yahoo!: cmeerw

...and what have you contributed to the Net?
Oct 24 2001