static member initilization
Ian Lance Taylor
iant@google.com
Tue Jul 10 12:24:00 GMT 2012
On Tue, Jul 10, 2012 at 5:07 AM, Mohsen Pahlevanzadeh
<mohsen@pahlevanzadeh.org> 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
More information about the Gcc-help
mailing list