Container class. compiler error

S

ScOe

when i try to initialize container i receive compiler error:
[Linker Error] Unresolved external 'TVecArray<int>::create()' referenced
from C:\- DEVELOP -\C++ BUILDER PROJECTS\IGRICE\IM_WIN\FORMMAIN.OBJ

TVecArray<int> test;

what did i do wrong ?
I'm using BCB5

code snipet:
template <class T> class TVecArray
{
public:
....
TVecArray () {create ();}
....
private:
iterator data;
iterator limit;
iterator avail;

std::allocator<T> alloc;

void create ();
....
};
template <class T> void TVecArray<T>::create ()
{
data = avail = limit = 0;
}
 
K

Karthik Kumar

ScOe said:
when i try to initialize container i receive compiler error:
[Linker Error] Unresolved external 'TVecArray<int>::create()' referenced
from C:\- DEVELOP -\C++ BUILDER PROJECTS\IGRICE\IM_WIN\FORMMAIN.OBJ

TVecArray<int> test;

what did i do wrong ?
I'm using BCB5

code snipet:
template <class T> class TVecArray

As a matter of style and for better readability,
use typename here instead of class.
{
public:
...
TVecArray () {create ();}
...
private:
iterator data;
iterator limit;
iterator avail;

std::allocator<T> alloc;

void create ();
...
};
template <class T> void TVecArray<T>::create ()
{
data = avail = limit = 0;
}

And are you having this implementation in a different file other
than the file where you defined the templates ? You can't have it that
way. The declaration and the definition ought to be in the same file.
 
S

ScOe

And are you having this implementation in a different file other
than the file where you defined the templates ? You can't have it that
way. The declaration and the definition ought to be in the same file.
Well, that was exactly what i did.
Thanx for help ... now it's working fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,183
Messages
2,570,970
Members
47,525
Latest member
emmawilsonpark

Latest Threads

Top