C++ templates

Benjamin Ellis bmellis at uark.edu
Thu Nov 16 22:14:07 GMT 2000


> My Problem is that I'd like to implement a class-contructor, that takes  the
> generic types of my template as argument. When I'm defining the method
> within  the class declaration, everything works fine, but after spliting the
> class code apart, into .cpp and .hpp the compiler nervs me, that the > > 
>constructor's arguments are not enough defined... Could anyone help me?

I'm not sure if this will answer your question or not... but say you have 
this class declaration:

----------------------------------------

template <class T> 
class MyClass
{
     MyClass(T);

     void SomeFunction();
};

-----------------------------------------

you would therefore, in a seperate file, declare the function definitions as 
this:

------------------------------------------

template <class T>
MyClass<T>::MyClass(T genericDataType)
{
     //........
}

and ...

template <class T>
void MyClass<T>::SomeFunction()
{
     //........
}

--------------------------------------------

Remember, even if some of your class methods don't use the template type, 
they still have to be defined as a template function.

hope that helps.. make sure you pay attention to how the class methods are 
written in the .cpp file as shown above.

-Ben

-
to unsubscribe from this list send an email to kdevelop-request at kdevelop.org with the following body:
unsubscribe »your-email-address«



More information about the KDevelop mailing list