www.digitalmars.com Home | Search | C & C++ | D | DMDScript | News Groups | index | prev | next
Archives

D Programming
D
D.gnu
digitalmars.D
digitalmars.D.bugs
digitalmars.D.dtl
digitalmars.D.dwt
digitalmars.D.announce
digitalmars.D.learn
digitalmars.D.debugger

C/C++ Programming
c++
c++.announce
c++.atl
c++.beta
c++.chat
c++.command-line
c++.dos
c++.dos.16-bits
c++.dos.32-bits
c++.idde
c++.mfc
c++.rtl
c++.stl
c++.stl.hp
c++.stl.port
c++.stl.sgi
c++.stlsoft
c++.windows
c++.windows.16-bits
c++.windows.32-bits
c++.wxwindows

digitalmars.empire
digitalmars.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