We know that it is better to write the declarations of a class in header file
And it's definition in another source file

if the class is template I have a problem to link the two files header and source it will appear two errors about linking

In the same class mentioned above I want to declare some friend functions has return type and input argument of the same class data type in the class and define it outside the class as usual

I have another problem in linking I don't know the reason

plz if any one have the answe support me

thank to all in advance

Let's start with the first problem and see how that goes. Unless you're using a compiler that supports export (you probably aren't), templates can't be split into separate declaration and definition files. You have to provide the definition of the template in the header.

thank you Narue for your help

i want to told you i work on visual studio 2005

and what do you mean by export

thank you Dave Sinkula for your link

The reason for linker error is that the definition of the function template has not been instantiated. In order for a template to be instantiated, the compiler must know which definition should be instantiated and for what template arguments it should be instantiated. Unfortunately, these two pieces of information are in files that are compiled separately. Therefore, when our compiler sees the call to somefunction() but has no definition in sight to instantiate this function, it just assumes that such a definition is provided elsewhere and creates a reference (for the linker to resolve) to that definition. On the other hand, when the compiler processes the file(.cpp), it has no indication at that point that it must instantiate the template definition it contains for specific arguments.

>i want to told you i work on visual studio 2005
You don't have export.

>and what do you mean by export
It's a feature of C++ that supports what you're trying to do. But it's difficult to implement properly, and not many compilers have it.

What about friend function problem
I work with the link passed by Dave Sinkula

I hope that I make it correctly
BUT the program has linking error

I have another question about

Reading Excel sheet columns and rows from C++ code
If there is any library support that pleas support me by it