|
-
February 6th, 2004, 02:13 PM
#1
complicated template
Hi Gurus,
I have a problem with templates.
Here is a simplified version of my problem..
Any suggestion will be very appreciated.
In main code I call this
CMainEtc::OnClickOK()
{
CTrioGeneral tg;
tg.HelloThere();
}
I gets the following error.
error LNK2019: unresolved external symbol
"public: __thiscall CTrioGeneral::CTrioGeneral(void)"
(??0CTrioGeneral@@QAE@XZ) referenced in function
"public: void __thiscall CDenemeTemplDlg::OnBnClickedTest(void)"
(?OnBnClickedButton1@CDenemeTemplDlg@@QAEXXZ)
Here is the simplified code
//-----------------------------------------------------------//
template< class TXXX, class TYYY, class TZZZ >
class CTrio
{
public:
CTrio(){};
~CTrio(){};
TXXX* m_pXXX;
TYYY* m_pYYY;
TZZZ * m_pZZZ;
};
//-----------------------------------------------------------//
template<class TYYY, class TZZZ >
class CCouple
{
public:
CCouple(){};
~CCouple(){};
TYYY* m_pYYY;
TZZZ * m_pZZZ;
};
//-----------------------------------------------------------//
template< class TZZZ >
class CSingle
{
public:
CSingle(){};
~CSingle(){};
TZZZ * m_pZZZ;
};
//----------------//
class CBit
{
public:
CBit(){};
~CBit(){};
};
//-----------------------------------------------------------//
class CSingleEx : public CSingle<CBit>
{
public:
CSingleEx(){};
// no destructor
};
//-----------------------------------------------------------//
template<class TYYY>
class CTrioEx : public CTrio<CCouple<TYYY, CBit>, TYYY, CBit>
{
public:
CTrioEx(){};
// no destructor
};
//-----------------------------------------------------------//
class CTrioGeneral : public CTrioEx<CSingleEx>
{
public:
CTrioGeneral();
// no destructor
void HelloThere(){ AfxMessageBox("Hello There"); };
};
-
February 6th, 2004, 02:35 PM
#2
-
February 7th, 2004, 05:00 AM
#3
?
It says that, write whole things in .H file instead of .CPP.
I should say that, I have already written everything about template in .H file.
Any more suggestion ?
-
February 7th, 2004, 05:24 AM
#4
Sorry,
I have realized that I have not implemented the constructor of last class; i.e. class CTrioGeneral()
Last class should be like following..
Anyway... Totally we have good(?) example of templates here 
Thanks everybody!
//-----------------------------------------------------------//
class CTrioGeneral : public CTrioEx<CSingleEx>
{
public:
CTrioGeneral(){} ; //error here
// no destructor
void HelloThere(){ AfxMessageBox("Hello There"); };
};
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|