static member initilization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]


Dear all,
i have the following claas:
////////////////////////////
template < class Class, typename ReturnType,typename Parameter1 = int ,
typename Parameter2 = int, typename Parameter3 = int, typename
Parameter4 = int >
class EventHandlerAbstract
{
public:
static std::vector< std::pair< int , string > > *eventList  ;
static std::vector<std::pair< int , string > > &eventStaticMemberVectorInit();
}
///////////////////////////
and following cpp file:
///////////////////////////
template <>
std::vector<std::pair< int ,string > > &EventHandlerAbstract< test,int,int,int,int,int >::eventStaticMemberVectorInit()
{
static bool first_time = true;
std::vector< std::pair< int , string > > vector_;
if (first_time)
{
vector_.push_back(std::pair< int ,string > (0,"zero"));
first_time = false;
}
printf("%s \n",vector_[0].second.c_str());
return  vector_;
}
/////////////////////////
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
////////////////////////////////////////////////////////

i write according to format of initialization , but i get error.
I'm confusion.....

--mohsen

Attachment: signature.asc
Description: This is a digitally signed message part


[Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

Add to Google