Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

about template in file.h and file.cpp -- error Visual C .Net

Status
Not open for further replies.

EdwinUgarte

Programmer
Jun 10, 2003
2
AR
Hello people...
I need to create a list and other classes parametrizadas in Visual Studio .Net.
For I am using the template...
For the case of the list in lista.h in which I declare and I define the class with their functions... Until there all well
But when I try to separate the declaration of the class:

the declaration (in " lista.h "):

#IFNDEF LISTA_DESAFIO
#DEFINE LISTA_DESAFIO

template<class elem>
clever class {..
..
};
#endif

The definition (in &quot; lista.cpp &quot;):

template <class elem>
it lists <elem>::lista () / /Constructor
{
sig=NULL;
}

template<class elem>
it lists <elem>::~lista () / /Destructor
{
}

and other functions more....
.....
....

a third file from where I call it (programa.cpp):

#include &quot; lista.h &quot;
...

void main ()
{
it lists <int> miLista;

}

Then treatment of compiling the program, and the visual one gives me an error

fatal error C1010: unexpected end of file while looking for precompiled header directive

Does somebody know as correcting this problem?


 
Not used visual studio .net in anger - but when I have seen this in vis studio 6 (and before) - it is because the file you get the error is not exempted from the pre-compiled header list, and does not have the #include &quot;stdafx.h&quot; in it.

Add #include &quot;stdafx.h&quot; or whatever the .net equivalent is - as one of the first lines in the file.

M.


Hollingside Technologies, Making Technology work for you.
 
You can't separate template declarations and definitions like that. Just put them all in the header.

For more info, read my FAQ at the C++ UNIX forum.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top