[Bug c++/42330] undefined reference to "static const int" in class when passing as "const int &" to a function

aijunbai at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Dec 8 11:52:00 GMT 2009



------- Comment #5 from aijunbai at gmail dot com  2009-12-08 11:52 -------
(In reply to comment #4)
> (In reply to comment #3)
> > (In reply to comment #2)
> > > and i don't want to write lots of "const int A<N>::i"...
> > 
> > You have to, your code is not valid if you use A::i in the program but it has
> > no definition.  This is not a compiler bug.
> 
> Actually you don't have to write lots, just one:
> 
> template<int N> const A<N>::i;
> 

I tried so, but it seems do not work, could you please explain more detailedly?
thx~


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=42330



More information about the Gcc-bugs mailing list