- To: Mohsen Pahlevanzadeh <mohsen@xxxxxxxxxxxxxxxxx>
- Subject: Re: static member initilization
- From: Ian Lance Taylor <iant@xxxxxxxxxx>
- Date: Tue, 10 Jul 2012 05:23:47 -0700
- Cc: gcc-help@xxxxxxxxxxx
- Comment: DKIM? See http://www.dkim.org
- Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys
- In-reply-to: <1341922056.5396.28.camel@debian>
On Tue, Jul 10, 2012 at 5:07 AM, Mohsen Pahlevanzadeh
<mohsen@xxxxxxxxxxxxxxxxx> wrote:
>
> but when i initialize my vector such as following line:
> ////////////////////////////
> template < > std::pair<int, string> EventHandlerAbstract<
> test,int,int,int,int,int >::eventList =
> &EventHandlerAbstract<test,int,int,int,int,int>::eventStaticMemberVectorInit();
> ///////////////////////////////////////////////////////////
> i get the following errors:
> ////////////////////////////////////////////////////////
> error: ‘EventHandlerAbstract<test, int, int, int, int, int>::eventList’
> has a previous declaration as ‘std::vector<std::pair<int,
> std::basic_string<char> > >* EventHandlerAbstract<test, int, int, int,
> int, int>::eventList’
> main.cpp:9:178: error: ‘EventHandlerAbstract<test, int, int, int, int,
> int>::eventList’ cannot be initialized by a non-constant expression when
> being declared
> ////////////////////////////////////////////////////////
1) This does not look like a question about how to use GCC. It looks
like a question about how to use C++.
2) Please try hard to send a complete self-contained example, rather
than a collection of little bits of code. Often the attempt to create
an example will answer the question for you.
3) The declaration of eventList within the class uses
std::vector<std::pair<>>, the declaration in the file uses just
std::pair, without std::vector. That is probably the root cause of
your problem.
Ian
[Linux C Programming]
[Linux Kernel]
[eCos]
[Fedora Development]
[Fedora Announce]
[Autoconf]
[The DWARVES Debugging Tools]
[Yosemite Campsites]
[Yosemite News]
[Linux GCC]