Click here to Skip to main content
15,913,908 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Displaying continous values Pin
Rinu_Raj14-Sep-06 23:01
Rinu_Raj14-Sep-06 23:01 
QuestionProblem with fonts in DC ? Pin
Vinod Sankaranarayanan14-Sep-06 22:49
Vinod Sankaranarayanan14-Sep-06 22:49 
AnswerRe: Problem with fonts in DC ? Pin
kk.tvm14-Sep-06 22:52
kk.tvm14-Sep-06 22:52 
AnswerRe: Problem with fonts in DC ? Pin
Steve S14-Sep-06 22:52
Steve S14-Sep-06 22:52 
AnswerRe: Problem with fonts in DC ? Pin
Hamid_RT15-Sep-06 7:26
Hamid_RT15-Sep-06 7:26 
QuestionLinking Error when use Class Template in VC6 [modified] Pin
Andy Rama14-Sep-06 20:42
Andy Rama14-Sep-06 20:42 
AnswerRe: Linking Error when use Class Template in VC6 [modified] Pin
Mr.Brainley14-Sep-06 21:48
Mr.Brainley14-Sep-06 21:48 
AnswerRe: Linking Error when use Class Template in VC6 Pin
Nibu babu thomas14-Sep-06 21:56
Nibu babu thomas14-Sep-06 21:56 
Aniket Salunkhe wrote:
It shows Linking error for the member functions of class. But when I remove template from Class the program runs well; even when I write all code (Class with template) in single "Program01.cpp" File then also it runs well.
Then what might be the problem in the above code?


Template classes should be defined and declared in .h files so that the compiler can generate code for these classes when an instantiation is required.

Because templates are compiled when required, this forces a restriction for multi-file projects: the implementation (definition) of a template class or function must be in the same file as its declaration. That means that we cannot separate the interface in a separate header file, and that we must include both interface and implementation in any file that uses the templates.

Remove definitions from .cpp file to .h file.

These days compilers do allow you to forward declare template types, but some compilers don't yet support them.

// In AClass.h
template < class T >
class AClass
{
    int ATemplateFunction( T aObj );
};
 
// Don't define this function in AClass.cpp but in AClass.h
template< class T >
int AClass< T >::ATemplateFunction( T aObj )
{
   // Have fun
   return 1;
}



Nibu thomas
A Developer

Programming tips[^]  My site[^]

GeneralRe: Linking Error when use Class Template in VC6 Pin
Andy Rama14-Sep-06 22:09
Andy Rama14-Sep-06 22:09 
GeneralRe: Linking Error when use Class Template in VC6 Pin
Nibu babu thomas14-Sep-06 22:19
Nibu babu thomas14-Sep-06 22:19 
GeneralRe: Linking Error when use Class Template in VC6 Pin
Andy Rama14-Sep-06 22:44
Andy Rama14-Sep-06 22:44 
GeneralRe: Linking Error when use Class Template in VC6 Pin
Nibu babu thomas14-Sep-06 22:46
Nibu babu thomas14-Sep-06 22:46 
QuestionHow to dynamically change the toolbar tip in MFC? Pin
ziyoo14-Sep-06 20:41
ziyoo14-Sep-06 20:41 
AnswerRe: How to dynamically change the toolbar tip in MFC? Pin
ziyoo15-Sep-06 15:30
ziyoo15-Sep-06 15:30 
Questionimages problem Pin
radhika2814-Sep-06 20:08
radhika2814-Sep-06 20:08 
AnswerRe: images problem Pin
_AnsHUMAN_ 14-Sep-06 20:21
_AnsHUMAN_ 14-Sep-06 20:21 
GeneralRe: images problem Pin
radhika2814-Sep-06 20:24
radhika2814-Sep-06 20:24 
GeneralRe: images problem Pin
ThatsAlok14-Sep-06 20:43
ThatsAlok14-Sep-06 20:43 
Questionreading .pst file Pin
neha.agarwal2714-Sep-06 19:01
neha.agarwal2714-Sep-06 19:01 
AnswerRe: reading .pst file Pin
Christian Graus14-Sep-06 19:14
protectorChristian Graus14-Sep-06 19:14 
GeneralRe: reading .pst file Pin
neha.agarwal2714-Sep-06 19:46
neha.agarwal2714-Sep-06 19:46 
GeneralRe: reading .pst file Pin
Christian Graus14-Sep-06 20:06
protectorChristian Graus14-Sep-06 20:06 
GeneralRe: reading .pst file Pin
neha.agarwal2714-Sep-06 20:20
neha.agarwal2714-Sep-06 20:20 
GeneralRe: reading .pst file Pin
Christian Graus14-Sep-06 21:13
protectorChristian Graus14-Sep-06 21:13 
AnswerRe: reading .pst file Pin
Hamid_RT14-Sep-06 20:32
Hamid_RT14-Sep-06 20:32 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.