help-gplusplus
[Top][All Lists]
Advanced

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

Defining template class methods outside class definition


From: Martin Magnusson
Subject: Defining template class methods outside class definition
Date: Wed, 11 Aug 2004 16:56:23 +0200
User-agent: Mozilla Thunderbird 0.7a (Windows/20040614)

I have a templated class, and I want to keep the implementation in a separate file, and not in the header file. Shouldn't the code below work? When I run the code below through g++ 3.3.1 (Cygwin) I get the following message

test.cpp:10: error: syntax error before `::' token
test.cpp:11: error: invalid use of template-name 'vertex' in a declarator
test.cpp:11: error: syntax error before `{' token

--------------------------------------
template<int N>
class vertex
{
public:
  vertex();
  int elements[N];
};

template<int N>
vertex::vertex()    // LINE 10
{
  elements[0] = 0;
}
--------------------------------------

/ martin


reply via email to

[Prev in Thread] Current Thread [Next in Thread]